royale-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [royale-asjs] joshtynjala commented on issue #885: ... arguments parity from Flex and Royale
Date Tue, 07 Jul 2020 15:58:01 GMT

joshtynjala commented on issue #885:
URL: https://github.com/apache/royale-asjs/issues/885#issuecomment-654960494


   It looks like there are a couple of things going on here.
   
   1) First, you are confusing the implement implicit `arguments` object that is available
in every function in JS/AS3 with AS3's optional "rest" parameter. They are actually two different
things. `arguments` is always available, and doesn't need to be declared. The "rest" parameter
must be declared.
   
   You can actually see that this is the case because the arguments.html link that you included
recommends using the "rest" parameter instead of `arguments`:
   
   > ActionScript 3.0 includes a new ...(rest) keyword that is recommended instead of the
arguments class.
   
   2) There does seem to be some kind of bug in Royale, though. It looks like when you name
the "rest" parameter `arguments`, it conflicts with the implicit `arguments` object. Perhaps
JS behaves a little bit differently than AS3 and doesn't allow the implicit `arguments` variable
to be shadowed. So, for our generated JS, the compiler probably need to check if the "rest"
parameter is named `arguments` and then use a different name instead.
   
   It's worth mentioning that the final "rest" parameter after the ... can be named anything.
It is not required to be named `arguments` or `Arguments`. Because it is called a "rest" parameter,
people often name it `rest`. But you could choose `params`, `args`, `extra`, or `royaleIsSuperCool`
if you wanted, and they should all work fine.
   
   ```
   public function call(...rest):void
   {
   }
   ```
   
   I would recommend avoiding `arguments` as the name, though, even after this issue is fixed
in Royale. Since `arguments` is also the existing name of something different, you have the
potential of confusing people who are not reading your code carefully enough.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message