[Scilab-users] Question on constant variables

 Classic List Threaded
3 messages
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Question on constant variables

 Dear all, What is the reason why %pi, %e, %i, %f, %t are considered variables (see help percent) when they are really constants? If %pi were a variable with the only detail that it has a preassigned value (while a bit dangerous, it could have been a possibility), then this would be possible: --> %pi = 2 However, one gets the following warning: Redefining permanent variable. This is misleading since one would think that the value has been indeed changed, but entering --> %pi produces  %pi  =    3.1415927 That's pi, not 2! So it would be better an error message such as Attempt to redefine permanent variable not allowed. Now, a similar attempt such as --> %f = 2 yields a completely different message: Error: syntax error, unexpected =, expecting end of file And, of course, the result of invoking %f keeps being F. Regards, Federico Miyara   _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Question on constant variables

 Hello Frederico,     Le Mercredi, Novembre 27, 2019 22:51 CET, Federico Miyara <[hidden email]> a écrit:   > > Dear all, > > What is the reason why %pi, %e, %i, %f, %t are considered variables (see > help percent) when they are really constants? Maybe because the actual variables, if they are scalar, are called constants ( see  "a=1;typeof(a)" for example )! Confusing, he? :-). > > If %pi were a variable with the only detail that it has a preassigned > value (while a bit dangerous, it could have been a possibility), then > this would be possible: > > --> %pi = 2 > > However, one gets the following warning: > > Redefining permanent variable. > > This is misleading since one would think that the value has been indeed > changed, but entering > > --> %pi > > produces > >   %pi  = > >     3.1415927 > > That's pi, not 2! > > So it would be better an error message such as > > Attempt to redefine permanent variable not allowed. I agree with you. Could you fill a bug and propose your improved error message? > > Now, a similar attempt such as > > --> %f = 2 > > yields a completely different message: > > Error: syntax error, unexpected =, expecting end of file This one is weird and also misleading. I wonder whether this is due to the fact that the parser is trying to detect cases where someone wrote "if a=1 then" instead of "if a==1 then". I think the "if a=1 then" syntax used to be valid and got deprecated at some point. Antoine > > And, of course, the result of invoking %f keeps being F. > > Regards, > > Federico Miyara > > _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Question on constant variables

 Le 28/11/2019 à 09:06, Antoine Monmayrant a écrit : ```Hello Frederico, Le Mercredi, Novembre 27, 2019 22:51 CET, Federico Miyara [hidden email] a écrit: ``` ```Dear all, What is the reason why %pi, %e, %i, %f, %t are considered variables (see help percent) when they are really constants? ``` ```Maybe because the actual variables, if they are scalar, are called constants ( see "a=1;typeof(a)" for example )! Confusing, he? :-). ``` ```If %pi were a variable with the only detail that it has a preassigned value (while a bit dangerous, it could have been a possibility), then this would be possible: --> %pi = 2 However, one gets the following warning: Redefining permanent variable. This is misleading since one would think that the value has been indeed changed, but entering --> %pi produces  %pi  =    3.1415927 That's pi, not 2! So it would be better an error message such as Attempt to redefine permanent variable not allowed. ``` `I agree with you. ` So do i. Or "Can't set a protected variable" or something similar could be OK as well (nothing is really permanent ... :-) `Could you fill a bug and propose your improved error message?` Excellent suggestion. ```Now, a similar attempt such as --> %f = 2 yields a completely different message: Error: syntax error, unexpected =, expecting end of file``` This is indeed a very surprising change specific to %T and %F, introduced with Scilab 6.0.0. It is reported as bug 15029. Regards Samuel _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users