[scilab-Users] Variables scope in functions

Adrien Vogt-Schilb vogt at centre-cired.fr
Fri Mar 25 12:24:32 CET 2011


Hi

workarounds use argn(2) inside functions, and use exotic names for 
variables inside functions.

eg:

function y=MyPrettyFunction(mpf_a,mpf_x)

y = mpf_x^mpf_a


endfunction

Le 25/03/2011 12:20, Ruben Bibas a écrit :
> Ok, thanks for the answer.
> Ruben
>
> On Fri, Mar 25, 2011 at 11:30 AM, Sylvestre Ledru
> <sylvestre.ledru at scilab.org>  wrote:
>> We might introduce in a future release of the 6 family a strict mode for
>> such things... but it won't happen soon...
>>
>> S
>>
>> Le vendredi 25 mars 2011 à 10:02 +0100, Ruben Bibas a écrit :
>>> Hi,
>>> Thanks for the anser.
>>> Yes, I know it is the normal behaviour. I am just asking if there is a
>>> way for telling Scilab to behave differently ?
>>> Thanks
>>>
>>> 2011/3/25 Stéphane Mottelet<stephane.mottelet at utc.fr>:
>>>> Le 25/03/2011 08:59, Ruben Bibas a écrit :
>>>>> Hello,
>>>>> I used to use Matlab and now I am using Scilab a lot.
>>>>> Is it possible to use functions in Scilab and have a variable scope
>>>>> handling the same way Matlab is: it does not know of any variables
>>>>> except the arguments of the functions ?
>>>>> I find it very disturbing that function can know external variables
>>>>> which are not global.
>>>>> Besides, sometimes if you do use this functionality with matrices, and
>>>>> try to redefine part of the matrix, it gets truncated.
>>>>> (If t is defined outside of a function as a 10x12 matrix, and you say
>>>>> inside the function t(3,8)=0, it gets truncated to 3x8.)
>>>>>
>>>>> Anyhow, if there is a scopeMode = 0 switch, I would be very happy to
>>>>> hear about it and if not, I would like to suggest it.
>>>>>
>>>>> Thank you for your help!
>>>>>
>>>>> Ruben
>>>> Hi,
>>>>
>>>> this is the normal Scilab behavior :
>>>>
>>>> http://wiki.scilab.org/howto/global_and_local_variables
>>>>
>>>> S.
>>>>
>>
>>


-- 

*Adrien Vogt-Schilb*

Research Fellow

vogt at centre-cired.fr <mailto:vogt at centre-cired.fr>

Tel: (+33) 1 43 94 73 96

Fax: (+33) 1 43 94 73 70

CIRED

	

45 bis, Av de la Belle Gabrielle

F-94736 Nogent-sur-Marne

http://www.centre-cired.fr/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110325/f13f92a3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logocired.png
Type: image/png
Size: 4092 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20110325/f13f92a3/attachment.png>


More information about the users mailing list