[Scilab-users] Variables visibility in functions

Antoine Monmayrant antoine.monmayrant at laas.fr
Thu May 7 16:32:06 CEST 2020


Hello,

I am not sure to understand what you want to achieve here.
It is not really clear for me.
You might be able to hack something using 'exists" but I am not sure 
that it would fit nicely with the way Scilab is designed...


Antoine


On 07/05/2020 14:01, kjubo wrote:
> Dear all,
>
> I would like to ask you, how can I disable visibility of variables from
> workspace for functions.
>
> I need to be sure, that function which I convert from script file, will not
> use any variable, which is not in it input, or defined inside the function
> itself.
>
> Please see examples below.
>
> Is this possible?
>          
> Thank you
>          
> BR
>          
> JK
>
>          example 1:
>
>          a = 3
>          function fx = some_fun(x,a)
>              fx = x+a
>          endfunction
>
>          calling some_fun(5) now return 3+5, but I need to be an error.
>
>
>          example 2:
>
>          a = 3
>          function fx = some_fun(x)
>              fx = x+a
>          endfunction
>
>          I need also error, as variable a should be passed as input argument
> or defined inside some_fun body
>
>
>
> --
> Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>



More information about the users mailing list