From stephane.mottelet at utc.fr Fri Feb 26 14:50:00 2021 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Fri, 26 Feb 2021 14:50:00 +0100 Subject: [Scilab-Dev] [Scilab-users] Variable scope in Scilab In-Reply-To: References: Message-ID: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr> Hi devs, Just after changing the rule in macro.cpp I see this at startup, and I am laughing out loud ;-) Scilab branch-6.1 (Feb 19 2021, 14:37:51) at line??? 44 of function mdelete??????????? ( /Users/mottelet/git/scilab_6.1.orig/scilab/modules/fileio/macros/mdelete.sci line 57 ) at line??? 26 of function atomsAUWriteAccess ( /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atoms_internals/atomsAUWriteAccess.sci line 42 ) at line??? 11 of function atomsSystemInit??? ( /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atomsSystemInit.sci line 27 ) Wrong number of input arguments. --> Does it mean that we use the "crappy shortcut" as a feature in Scilab internals ? S. Le 26/02/2021 ? 14:38, St?phane Mottelet a ?crit?: > Hi all, > > In Scilab the scope of variables is quite permissive but even in Julia > (really strict rules) we can have the following behavior: > > function y=f(x) > ?y=x+a; > end > > a=1; > f(2) > a=2; > f(3) > > -> a=1; > > --> f(2) > ?ans? = > > ?? 3. > > --> a=2; > > --> f(3) > ?ans? = > > ?? 5. > > Yesterday afternoon I was my students for a Scilab beginners tutorial, > and by accident one of them had "x" defined before in the main > workspace and tried to call f without arguments. I reproduce the > experiment here by explicitely defining x before the call: > > x=1; > f > > --> x=1; > > --> f > ?ans? = > > ?? 3. > > Allowing the function inner scope to see variables of the outer scope > is one thing, you may or may not agree this is not the point here, but > allowing to call f without arguments just because the formal input > parameter has the same symbol as an outer scope symbol is another > thing. I knew this was possible even if i never used such a feature, > but my students were so puzzled by this, particularly those who > already learned other low-level languages, that I decided to propose > the suppression of this, that I consider as a serious potential source > of many bugs. Don't tell me that this would break some user code > because I frankly have no consideration for this kind of crappy > shortcut and, sorry if it may sound rude, for programmers who use it... > > S. > -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet From stephane.mottelet at utc.fr Fri Feb 26 15:01:59 2021 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Fri, 26 Feb 2021 15:01:59 +0100 Subject: [Scilab-Dev] [Scilab-users] Variable scope in Scilab In-Reply-To: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr> References: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr> Message-ID: <6b4f57ea-e53e-182b-773a-33ce2f3a6ca9@utc.fr> Le 26/02/2021 ? 14:50, St?phane Mottelet a ?crit?: > Hi devs, > > Just after changing the rule in macro.cpp I see this at startup, and I > am laughing out loud ;-) > > Scilab branch-6.1 (Feb 19 2021, 14:37:51) > at line??? 44 of function mdelete??????????? ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/fileio/macros/mdelete.sci > line 57 ) > at line??? 26 of function atomsAUWriteAccess ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atoms_internals/atomsAUWriteAccess.sci > line 42 ) > at line??? 11 of function atomsSystemInit??? ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atomsSystemInit.sci > line 27 ) > > Wrong number of input arguments. > > --> > > Does it mean that we use the "crappy shortcut" as a feature in Scilab > internals ? of course nobody uses it, my patch waas a little bit rude. We have the right to call macros with less arguments than the number of formal input arguments, hence when inheriting the outer context then there is a complete confusion between the formal parameter name and the same name of a symbol in the outer context. Inheritance should be OK for all symbols BUT formal input parameters. S. > > S. > > Le 26/02/2021 ? 14:38, St?phane Mottelet a ?crit?: >> Hi all, >> >> In Scilab the scope of variables is quite permissive but even in >> Julia (really strict rules) we can have the following behavior: >> >> function y=f(x) >> ?y=x+a; >> end >> >> a=1; >> f(2) >> a=2; >> f(3) >> >> -> a=1; >> >> --> f(2) >> ?ans? = >> >> ?? 3. >> >> --> a=2; >> >> --> f(3) >> ?ans? = >> >> ?? 5. >> >> Yesterday afternoon I was my students for a Scilab beginners >> tutorial, and by accident one of them had "x" defined before in the >> main workspace and tried to call f without arguments. I reproduce the >> experiment here by explicitely defining x before the call: >> >> x=1; >> f >> >> --> x=1; >> >> --> f >> ?ans? = >> >> ?? 3. >> >> Allowing the function inner scope to see variables of the outer scope >> is one thing, you may or may not agree this is not the point here, >> but allowing to call f without arguments just because the formal >> input parameter has the same symbol as an outer scope symbol is >> another thing. I knew this was possible even if i never used such a >> feature, but my students were so puzzled by this, particularly those >> who already learned other low-level languages, that I decided to >> propose the suppression of this, that I consider as a serious >> potential source of many bugs. Don't tell me that this would break >> some user code because I frankly have no consideration for this kind >> of crappy shortcut and, sorry if it may sound rude, for programmers >> who use it... >> >> S. >> -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet From 017nks at gmail.com Fri Feb 26 15:05:42 2021 From: 017nks at gmail.com (Namrata Kumari) Date: Fri, 26 Feb 2021 19:35:42 +0530 Subject: [Scilab-Dev] [Scilab-users] Variable scope in Scilab In-Reply-To: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr> References: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr> Message-ID: Please remove me from this mailing list. Thank you, Namrata On Fri, Feb 26, 2021, 7:29 PM St?phane Mottelet wrote: > Hi devs, > > Just after changing the rule in macro.cpp I see this at startup, and I > am laughing out loud ;-) > > Scilab branch-6.1 (Feb 19 2021, 14:37:51) > at line 44 of function mdelete ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/fileio/macros/mdelete.sci > > line 57 ) > at line 26 of function atomsAUWriteAccess ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atoms_internals/atomsAUWriteAccess.sci > > line 42 ) > at line 11 of function atomsSystemInit ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atomsSystemInit.sci > > line 27 ) > > Wrong number of input arguments. > > --> > > Does it mean that we use the "crappy shortcut" as a feature in Scilab > internals ? > > S. > > Le 26/02/2021 ? 14:38, St?phane Mottelet a ?crit : > > Hi all, > > > > In Scilab the scope of variables is quite permissive but even in Julia > > (really strict rules) we can have the following behavior: > > > > function y=f(x) > > y=x+a; > > end > > > > a=1; > > f(2) > > a=2; > > f(3) > > > > -> a=1; > > > > --> f(2) > > ans = > > > > 3. > > > > --> a=2; > > > > --> f(3) > > ans = > > > > 5. > > > > Yesterday afternoon I was my students for a Scilab beginners tutorial, > > and by accident one of them had "x" defined before in the main > > workspace and tried to call f without arguments. I reproduce the > > experiment here by explicitely defining x before the call: > > > > x=1; > > f > > > > --> x=1; > > > > --> f > > ans = > > > > 3. > > > > Allowing the function inner scope to see variables of the outer scope > > is one thing, you may or may not agree this is not the point here, but > > allowing to call f without arguments just because the formal input > > parameter has the same symbol as an outer scope symbol is another > > thing. I knew this was possible even if i never used such a feature, > > but my students were so puzzled by this, particularly those who > > already learned other low-level languages, that I decided to propose > > the suppression of this, that I consider as a serious potential source > > of many bugs. Don't tell me that this would break some user code > > because I frankly have no consideration for this kind of crappy > > shortcut and, sorry if it may sound rude, for programmers who use it... > > > > S. > > > -- > St?phane Mottelet > Ing?nieur de recherche > EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable > D?partement G?nie des Proc?d?s Industriels > Sorbonne Universit?s - Universit? de Technologie de Compi?gne > CS 60319, 60203 Compi?gne cedex > Tel : +33(0)344234688 > http://www.utc.fr/~mottelet > > _______________________________________________ > dev mailing list > dev at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/dev > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.cheze at cea.fr Fri Feb 26 15:23:04 2021 From: david.cheze at cea.fr (CHEZE David 227480) Date: Fri, 26 Feb 2021 14:23:04 +0000 Subject: [Scilab-Dev] [Scilab-users] Variable scope in Scilab In-Reply-To: <6b4f57ea-e53e-182b-773a-33ce2f3a6ca9@utc.fr> References: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr>, <6b4f57ea-e53e-182b-773a-33ce2f3a6ca9@utc.fr> Message-ID: Hi all, I agree that such stricter management of parameters would be wise . David ________________________________________ De : dev [dev-bounces at lists.scilab.org] de la part de St?phane Mottelet [stephane.mottelet at utc.fr] Envoy? : vendredi 26 f?vrier 2021 15:01 ? : List dedicated to the development of Scilab Objet : Re: [Scilab-Dev] [Scilab-users] Variable scope in Scilab Le 26/02/2021 ? 14:50, St?phane Mottelet a ?crit : > Hi devs, > > Just after changing the rule in macro.cpp I see this at startup, and I > am laughing out loud ;-) > > Scilab branch-6.1 (Feb 19 2021, 14:37:51) > at line 44 of function mdelete ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/fileio/macros/mdelete.sci > line 57 ) > at line 26 of function atomsAUWriteAccess ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atoms_internals/atomsAUWriteAccess.sci > line 42 ) > at line 11 of function atomsSystemInit ( > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atomsSystemInit.sci > line 27 ) > > Wrong number of input arguments. > > --> > > Does it mean that we use the "crappy shortcut" as a feature in Scilab > internals ? of course nobody uses it, my patch waas a little bit rude. We have the right to call macros with less arguments than the number of formal input arguments, hence when inheriting the outer context then there is a complete confusion between the formal parameter name and the same name of a symbol in the outer context. Inheritance should be OK for all symbols BUT formal input parameters. S. > > S. > > Le 26/02/2021 ? 14:38, St?phane Mottelet a ?crit : >> Hi all, >> >> In Scilab the scope of variables is quite permissive but even in >> Julia (really strict rules) we can have the following behavior: >> >> function y=f(x) >> y=x+a; >> end >> >> a=1; >> f(2) >> a=2; >> f(3) >> >> -> a=1; >> >> --> f(2) >> ans = >> >> 3. >> >> --> a=2; >> >> --> f(3) >> ans = >> >> 5. >> >> Yesterday afternoon I was my students for a Scilab beginners >> tutorial, and by accident one of them had "x" defined before in the >> main workspace and tried to call f without arguments. I reproduce the >> experiment here by explicitely defining x before the call: >> >> x=1; >> f >> >> --> x=1; >> >> --> f >> ans = >> >> 3. >> >> Allowing the function inner scope to see variables of the outer scope >> is one thing, you may or may not agree this is not the point here, >> but allowing to call f without arguments just because the formal >> input parameter has the same symbol as an outer scope symbol is >> another thing. I knew this was possible even if i never used such a >> feature, but my students were so puzzled by this, particularly those >> who already learned other low-level languages, that I decided to >> propose the suppression of this, that I consider as a serious >> potential source of many bugs. Don't tell me that this would break >> some user code because I frankly have no consideration for this kind >> of crappy shortcut and, sorry if it may sound rude, for programmers >> who use it... >> >> S. >> -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet _______________________________________________ dev mailing list dev at lists.scilab.org http://lists.scilab.org/mailman/listinfo/dev From jicarrerom at unal.edu.co Fri Feb 26 16:32:00 2021 From: jicarrerom at unal.edu.co (javier ignacio carrero mantilla) Date: Fri, 26 Feb 2021 10:32:00 -0500 Subject: [Scilab-Dev] [Scilab-users] Variable scope in Scilab In-Reply-To: <6b4f57ea-e53e-182b-773a-33ce2f3a6ca9@utc.fr> References: <879aaea6-b43c-ce27-9757-aea9f3976b2e@utc.fr> <6b4f57ea-e53e-182b-773a-33ce2f3a6ca9@utc.fr> Message-ID: It is a curious example, but the availability of variables from the outer scope makes global variable declarations and multiple input arguments unnecessary in many cases. I think it deserves praise, in fact it is one of the best advantages of Scilab over certain software whose name starts with M. By the way, the pause - resume command pair is another Scilab's marvel, it should be fixed El vie, 26 feb 2021 a las 9:02, St?phane Mottelet () escribi?: > Le 26/02/2021 ? 14:50, St?phane Mottelet a ?crit : > > > Hi devs, > > > > Just after changing the rule in macro.cpp I see this at startup, and I > > am laughing out loud ;-) > > > > Scilab branch-6.1 (Feb 19 2021, 14:37:51) > > at line 44 of function mdelete ( > > > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/fileio/macros/mdelete.sci > > > line 57 ) > > at line 26 of function atomsAUWriteAccess ( > > > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atoms_internals/atomsAUWriteAccess.sci > > > line 42 ) > > at line 11 of function atomsSystemInit ( > > > /Users/mottelet/git/scilab_6.1.orig/scilab/modules/atoms/macros/atomsSystemInit.sci > > > line 27 ) > > > > Wrong number of input arguments. > > > > --> > > > > Does it mean that we use the "crappy shortcut" as a feature in Scilab > > internals ? > > of course nobody uses it, my patch waas a little bit rude. We have the > right to call macros with less arguments than the number of formal input > arguments, hence when inheriting the outer context then there is a > complete confusion between the formal parameter name and the same name > of a symbol in the outer context. Inheritance should be OK for all > symbols BUT formal input parameters. > > S. > > > > > S. > > > > Le 26/02/2021 ? 14:38, St?phane Mottelet a ?crit : > >> Hi all, > >> > >> In Scilab the scope of variables is quite permissive but even in > >> Julia (really strict rules) we can have the following behavior: > >> > >> function y=f(x) > >> y=x+a; > >> end > >> > >> a=1; > >> f(2) > >> a=2; > >> f(3) > >> > >> -> a=1; > >> > >> --> f(2) > >> ans = > >> > >> 3. > >> > >> --> a=2; > >> > >> --> f(3) > >> ans = > >> > >> 5. > >> > >> Yesterday afternoon I was my students for a Scilab beginners > >> tutorial, and by accident one of them had "x" defined before in the > >> main workspace and tried to call f without arguments. I reproduce the > >> experiment here by explicitely defining x before the call: > >> > >> x=1; > >> f > >> > >> --> x=1; > >> > >> --> f > >> ans = > >> > >> 3. > >> > >> Allowing the function inner scope to see variables of the outer scope > >> is one thing, you may or may not agree this is not the point here, > >> but allowing to call f without arguments just because the formal > >> input parameter has the same symbol as an outer scope symbol is > >> another thing. I knew this was possible even if i never used such a > >> feature, but my students were so puzzled by this, particularly those > >> who already learned other low-level languages, that I decided to > >> propose the suppression of this, that I consider as a serious > >> potential source of many bugs. Don't tell me that this would break > >> some user code because I frankly have no consideration for this kind > >> of crappy shortcut and, sorry if it may sound rude, for programmers > >> who use it... > >> > >> S. > >> > -- > St?phane Mottelet > Ing?nieur de recherche > EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable > D?partement G?nie des Proc?d?s Industriels > Sorbonne Universit?s - Universit? de Technologie de Compi?gne > CS 60319, 60203 Compi?gne cedex > Tel : +33(0)344234688 > http://www.utc.fr/~mottelet > > _______________________________________________ > dev mailing list > dev at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/dev > -- *Aviso legal:*?El contenido de este mensaje y los archivos adjuntos son confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. Se encuentran dirigidos s?lo para el uso del destinatario al cual van enviados. La reproducci?n, lectura y/o copia se encuentran prohibidas a cualquier persona diferente a este y puede ser ilegal. Si usted lo ha recibido por error, inf?rmenos y elim?nelo de su correo. Los Datos Personales ser?n tratados conforme a la Ley 1581 de 2012 y a nuestra Pol?tica de Datos Personales que podr? consultar en la p?gina web? www.unal.edu.co .*?*Las opiniones, informaciones, conclusiones y cualquier otro tipo de dato contenido en este correo electr?nico, no relacionados con la actividad de la Universidad Nacional de Colombia, se entender? como personales y de ninguna manera son avaladas por la Universidad. -------------- next part -------------- An HTML attachment was scrubbed... URL: