aharui commented on issue #78: Assign to Boolean variable does not convert to 
true or false, breaking loose comparison with ==
URL: https://github.com/apache/royale-compiler/issues/78#issuecomment-461674685
 
 
   Sounds like we have agreement on this particular topic.
   
   I do want to post some thoughts about "actionscript compliance".  IMO, it 
may never truly be practical to fully emulate the ActionScript runtime in the 
output and I think there are bigger fish to fry right now than to try to fully 
emulate everything the runtime can do.  So to me, the argument for compliance 
or consistency is not a clear winner.  The cost of the implementation in terms 
of code size and performance and committer time should be weighed against the 
likelihood of occurrences.  Sometimes, we should encourage or even require our 
early adopters to change their code.  
   
   The particular case I'm thinking of is the generic property read or write.  
Right now, if you have code like:
   
   ```
   function foo(bar:Object):void {
   bar.baz = 2;
   ```
   
   The compiler/transpiler will generate:
   
   `bar.baz = 2;`
   
   But that will not work in the browser if bar is XML or Proxy.  It will work 
in the Flash runtime.  I would not be in favor of replacing all property 
accesses with a call to some utility function that checks the type and makes 
the right call like the Flash runtime does.  IOW, to have some thing like:
   
   ```
   function Language.write(o:Object, prop:String, value:*):void
   {
      if (o is Proxy)
        o.setProperty(prop, value);
      else if (o is XML) {
        if (prop.charAt(0) == "@")
           o.setAttribute(prop, value);
        else
          o.replace(prop, value);
      }
      else
        o[prop] = value;
   } 
   ```
   
   And then generate:
   
   `Language.write(bar, "bar", 2);`
   
   I wouldn't want our default output to look like that and run each property 
read and write through another function call.  I don't think that would be the 
right first impression to give people.  Folks migrating are currently required 
to rewrite the code and inject the tests they need or strongly-type "bar" if 
they always know what it will be.  And that might need to be "good enough" for 
now.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to