[Scilab-users] ?==?utf-8?q? Question on constant variables

Antoine Monmayrant amonmayr at laas.fr
Thu Nov 28 09:06:26 CET 2019


Hello Frederico, 
 
 
Le Mercredi, Novembre 27, 2019 22:51 CET, Federico Miyara <fmiyara at fceia.unr.edu.ar> 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
> 
>




More information about the users mailing list