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-461611433
 
 
   AIUI, code brought into Royale from Flex will work for all booleans except 
those actually used in a boolean == boolean comparison.
   
   AIUI, assignments would not have to be changed unless later that code is 
used in a boolean == boolean comparison.
   
   We can and should provide XML and JSON "writers" that are knowledgable about 
types.  I'm not convinced that booleans are the only issue that XML and JSON 
writers can be smarter about and that "dumb" writers will get wrong.  I would 
venture to guess that any other scenarios we run into can be handled in the 
code that utilizes the boolean.  That is also PAYG.
   
   I believe we can solve the specific scenarios instead of generating lots of 
unnecessary initialization code "just-in-case".
   
   A backing variable is the variable that actually stores the value in a 
getter/setter.
   
   ```
   private var _foo:Boolean; // this is the backing variable
   public function get foo():Boolean
   {
      return _foo;
   }
   ```
   
   The backing variable can't be free if used in boolean==boolean compares.  
You have to pay for it when you need it.  That's PAYG for you.  But all other 
backing booleans can be free if they are never used in boolean==boolean 
compares.  You do not always need change detection in a setter.  Some 
ValueObjects can be "read-only" and are initialized by a network fetch and 
never change at runtime.  Then the code can be as simple as the "foo" example 
above and there will never be a need to have initialized the backing variable.
   
   IMO, this is a separate issue from the type-conversion changes for 
int/uint/number/string.  This is about initialization of booleans, not 
assigning values of different types.

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