[Scilab-users] Scilab 6 - Problem with scope and nested lists

Stéphane Mottelet stephane.mottelet at utc.fr
Fri Oct 16 13:39:51 CEST 2020


Hello,

I think that this is a sufficiently serious issue to diserve a report in 
bugzilla.scilab.org. But could you prepare a more compact example ?

S.

Le 16/10/2020 à 13:35, Arvid Rosén a écrit :
>
> Hi!
>
> We have found a tricky issue when moving over from Scilab 5 to Scilab 
> 6 in my organization. We have a lot of code which works with nested 
> lists, and functions modifying those lists. However, when a function 
> is called with some nested lists as an input argument, the body of 
> that function can change the value of the variable in the calling 
> scope. This was not the case in Scilab 5, and the issue is super 
> tricky to hunt down in our quite extensive code base. Below is a short 
> example of the problem, and how to reproduce it.
>
> I have also filed a bug report here: 
> https://bugzilla.scilab.org/show_bug.cgi?id=16556
>
> Is anyone else seeing this problem? And do you have any workarounds or 
> other suggestions?
>
> Cheers,
>
> Arvid
>
> ------
>
> // Define variables
>
> testArray = list();
>
> for i=1:1:10
>
>     testArray($+1) = list();
>
>     for j=1:1:10
>
>         testArray(i)($+1) = [];
>
>         testArray(i)(j).testMember = 1;
>
>     end
>
> end
>
> testArrayOrig = testArray;
>
> // Define functions
>
> function outArray = testFunc(inArray)
>
>     for i=1:1:10
>
>         for j=1:1:10
>
>             inArray(i)(j).testMember = 5
>
>         end
>
>     end
>
>     outArray = inArray;
>
> endfunction
>
> // Send the variable as argument to the function
>
> if %t
>
>     testArrayOut = testFunc2(testArray);
>
>     if testArrayOut(1)(1).testMember == testArray(1)(1).testMember
>
>         error("Error! inputArgument was changed by function");
>
>     end
>
> end
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

-- 
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20201016/21a85872/attachment.htm>


More information about the users mailing list