<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Frederico,</p>
<p>I do not have any problem with the variable scoping in Scilab and
as I said before, even in Julia there is a similar scoping (at
least for the particular case of functions). However, the status
of formal input and output parameters should prevent the scoping
to apply to them. For example, the following does also work (as an
addition to my previous example for the input parameter):<br>
<br>
function y=f(x)<br>
endfunction<br>
<br>
y=1<br>
f<br>
<br>
-> f<br>
ans =<br>
<br>
1.<br>
<br>
</p>
<p>Frankly speaking, allowing such a behavior is madness...</p>
<p>S.<br>
</p>
<span style="color:rgb(176,24,19);"></span>
<div class="moz-cite-prefix">Le 27/02/2021 à 01:33, Federico Miyara
a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:8ad002b5-ddc8-30b2-943f-5177d85adea7@fceia.unr.edu.ar">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<br>
<font face="Courier New">Stéphane,<br>
<br>
I agree it shouldn't happen, but the same moment access to outer
variables is granted you can't prevent such thing to happen
since inside the function all variables have a name which is
more than just a symbol or a mute variable, and this includes
undefined arguments.<br>
<br>
This scoping feature is dangerous and I don't think it would be
advisable to create a macro for general use exploiting it.<br>
<br>
May be someone can provide an example where it has been used
with profit or explain why it was originally introduced<br>
<br>
Regards,<br>
<br>
Federico Miyara<br>
<br>
</font>
<div class="moz-cite-prefix">On 26/02/2021 10:38, Stéphane
Mottelet wrote:<br>
</div>
<blockquote type="cite"
cite="mid:f7f76f97-11be-d4e3-06f6-53548cee9d8b@utc.fr">Hi all, <br>
<br>
In Scilab the scope of variables is quite permissive but even in
Julia (really strict rules) we can have the following behavior:
<br>
<br>
function y=f(x) <br>
y=x+a; <br>
end <br>
<br>
a=1; <br>
f(2) <br>
a=2; <br>
f(3) <br>
<br>
-> a=1; <br>
<br>
--> f(2) <br>
ans = <br>
<br>
3. <br>
<br>
--> a=2; <br>
<br>
--> f(3) <br>
ans = <br>
<br>
5. <br>
<br>
Yesterday afternoon I was my students for a Scilab beginners
tutorial, and by accident one of them had "x" defined before in
the main workspace and tried to call f without arguments. I
reproduce the experiment here by explicitely defining x before
the call: <br>
<br>
x=1; <br>
f <br>
<br>
--> x=1; <br>
<br>
--> f <br>
ans = <br>
<br>
3. <br>
<br>
Allowing the function inner scope to see variables of the outer
scope is one thing, you may or may not agree this is not the
point here, but allowing to call f without arguments just
because the formal input parameter has the same symbol as an
outer scope symbol is another thing. I knew this was possible
even if i never used such a feature, but my students were so
puzzled by this, particularly those who already learned other
low-level languages, that I decided to propose the suppression
of this, that I consider as a serious potential source of many
bugs. Don't tell me that this would break some user code because
I frankly have no consideration for this kind of crappy shortcut
and, sorry if it may sound rude, for programmers who use it... <br>
<br>
S. <br>
<br>
</blockquote>
<br>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top: 1px solid #D3D4DE;">
<tbody>
<tr>
<td style="width: 55px; padding-top: 18px;"><a
href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient"
target="_blank" moz-do-not-send="true"><img
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif"
alt="" style="width: 46px; height: 29px;"
moz-do-not-send="true" width="46" height="29"></a></td>
<td style="width: 470px; padding-top: 17px; color:
#41424e; font-size: 13px; font-family: Arial, Helvetica,
sans-serif; line-height: 18px;">Libre de virus. <a
href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient"
target="_blank" style="color: #4453ea;"
moz-do-not-send="true">www.avast.com</a> </td>
</tr>
</tbody>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
height="1" moz-do-not-send="true"> </a></div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
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
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet">http://www.utc.fr/~mottelet</a>
</pre>
</body>
</html>