<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <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;">
        <tr>
      <td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></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://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>           </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>