On 8/6/16, 9:39 PM, "Harbs" <harbs.li...@gmail.com> wrote:
>This discussion fell off the dev list... > >Begin forwarded message: > >> From: Harbs <harbs.li...@gmail.com> >> Subject: Re: FlexJS XML string assignment >> Date: August 6, 2016 at 11:50:29 PM GMT+3 >> To: Alex Harui <aha...@adobe.com> >> >> With the exception of XML, I cannot imagine a case where you’d want >>there to be an implicit conversion to a string. >> >> I’m fine with requiring an explicit conversion using toString() or “” + >>obj for the client when they want the conversion. >> >> I think it’s a reasonable trade-off to not add all those toStrings when >>they are not necessary. Adding null (and undefined) checks is even >>worse. I think a preference should be placed on compact JS code rather >>than 100% compatibility with Flash. IMO, we have 3 choices: 1) silently let JS code run differently from AS 2) warn if JS code is likely to run differently from AS 3) make the JS run the same as AS I think it will be too frustrating to not do (3). Subtle bugs, especially in code you may have had running for years might turn people away from FlexJS. I put together the following test: var foo:Object = {}; trace("Object", foo); foo.toString = function():String { return "foo"; }; var star:* = foo; var bar:String = star; trace("bar", bar); var baz:String = foo; trace("baz", bar); var xml:XML = <node attr="xmlattr" >xmltext</node>; bar = xml; trace("bar xmltext", bar); bar = xml.@attr; trace("bar xmlattr", bar); The compiler catches the assignment of baz to foo. But coercions from XML or XMLList or * are allowed by the compiler and the result seems to be that toString() is called. And if you set -strict=false, the assignment of baz to foo is allowed and again, toString() seems to get called. So, I think we are going to have to create a String conversion method that checks for null and calls toString() and have the compiler use that. I think the compiler's use of Number may be ok in the way it handles null. Thoughts? -Alex