No. You never get null for XML (unless it’s an XML typed variable which was
never set).
On Aug 8, 2016, at 12:45 AM, Alex Harui wrote:
>
>
> On 8/7/16, 2:04 PM, "Harbs" wrote:
>
>> Yes. That would be better (only 1.5KB), but only in this case. Assigning
>> a null value to a string should no
A directive is fine.
On Aug 8, 2016, at 8:35 AM, Alex Harui wrote:
>
>
> On 8/7/16, 2:04 PM, "Harbs" wrote:
>
>> Yes. That would be better (only 1.5KB), but only in this case. Assigning
>> a null value to a string should not covert it into an empty string.
>>
>> I was suggesting to have an
On 8/7/16, 2:04 PM, "Harbs" wrote:
>Yes. That would be better (only 1.5KB), but only in this case. Assigning
>a null value to a string should not covert it into an empty string.
>
>I was suggesting to have an option to not do any conversions.
>
>Right now my code works without any string conver
On 8/7/16, 2:04 PM, "Harbs" wrote:
>Yes. That would be better (only 1.5KB), but only in this case. Assigning
>a null value to a string should not covert it into an empty string.
For XML, do you ever get null?
-Alex
Yes. That would be better (only 1.5KB), but only in this case. Assigning a null
value to a string should not covert it into an empty string.
I was suggesting to have an option to not do any conversions.
Right now my code works without any string conversion at all. This is because
of the “string
On 8/7/16, 12:09 PM, "Harbs" wrote:
>Sure.
>
>Here’s a couple of examples:
>
>f.leading = xml.Properties.Leading;
>f.tracking = xml.@Tracking;
>
>I have 492 some assignments like this scattered across my code. Adding
>toString() to every one of these would add 5412 bytes to the final
>minified
On 8/7/16, 9:42 AM, "Harbs" wrote:
>Not faster. Smaller.
>
>I’m sure there’s no much difference speed-wise.
Why are you so sure? Function call overhead is significant in AS. Why
isn't it so in JS?
-Alex
Sure.
Here’s a couple of examples:
f.leading = xml.Properties.Leading;
f.tracking = xml.@Tracking;
I have 492 some assignments like this scattered across my code. Adding
toString() to every one of these would add 5412 bytes to the final minified
code. That’s not including non-XML assignments t
Not faster. Smaller.
I’m sure there’s no much difference speed-wise.
Once we add type safety to default values, it’ll be a bigger difference in
terms of code size.
On Aug 7, 2016, at 5:47 PM, Alex Harui wrote:
>
>
> On 8/7/16, 2:19 AM, "Harbs" wrote:
>
>> BTW, I think another change to La
On 8/7/16, 1:55 AM, "Harbs" wrote:
>To sum up:
>
>There are a number of issues involved here.
>
>What started with a concern about implicit type conversions on XML turned
>into a much broader issue.
>
>In ActionScript, when you assign any object type to typed variable of a
>primitive type (or re
On 8/7/16, 2:19 AM, "Harbs" wrote:
>BTW, I think another change to Language is a good idea:
>
>Currently default function parameters are compiled like this:
>
>public static function getBottomValue(value:Object, values:Object,
>reference:Number = NaN):Number
>{
>return getSideValue(value, v
> One thing that might not be clear:
>
> Coercion should only happen on *assignment*. Coercion on comparisons should
> not happen because the conversions happen implicitly in the JS engine if
> required.
>
> On Aug 7, 2016, at 7:39 AM, Harbs wrote:
>
>> This dis
bs
>> Subject: Re: FlexJS XML string assignment
>> Date: August 6, 2016 at 11:50:29 PM GMT+3
>> To: Alex Harui
>>
>> 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
On 8/6/16, 9:39 PM, "Harbs" wrote:
>This discussion fell off the dev list...
>
>Begin forwarded message:
>
>> From: Harbs
>> Subject: Re: FlexJS XML string assignment
>> Date: August 6, 2016 at 11:50:29 PM GMT+3
>> To: Alex Harui
>>
&
This discussion fell off the dev list...
Begin forwarded message:
> From: Harbs
> Subject: Re: FlexJS XML string assignment
> Date: August 6, 2016 at 11:50:29 PM GMT+3
> To: Alex Harui
>
> With the exception of XML, I cannot imagine a case where you’d want there to
On 8/5/16, 8:05 AM, "Harbs" wrote:
>I just checked and Number(obj) is equivalent to Number(obj.valueOf())
>
>Like so:
>var a = {valueOf : function(){return "5"},toString:function(){return "6”}}
>
>Number(a) //5
>Number(a.valueOf()) //5
>Number(a.toString()) //6
>
>So valueOf() needs to return a
I just checked and Number(obj) is equivalent to Number(obj.valueOf())
Like so:
var a = {valueOf : function(){return "5"},toString:function(){return "6”}}
Number(a) //5
Number(a.valueOf()) //5
Number(a.toString()) //6
So valueOf() needs to return a value that Number will properly accept.
Harbs
On second thought, this is probably wrong.
Number(xml) is probably enough as Number should call toString() and deal with
all number types correctly.
On Aug 5, 2016, at 5:42 PM, Harbs wrote:
> If it knows it’s being assigned to a Number, I think it should call
> valueOf(), or possibly(Number(x
For cases where the compiler knows that XML is being assigned to a string, it
should add toString().
If it knows it’s being assigned to a Number, I think it should call valueOf(),
or possibly(Number(xml.valueOf())
There will likely be cases where the compiler will not know the types that the
X
I have not spent time thinking about this, but the compiler generally
knows the destination type. The compiler is going to have to learn when
to inject coercion code where AS would do an implicit conversion that JS
won't.
So fundamentally: what does XML valueOf do in AS? The XML JS
implementatio
I implemented this locally and the idea works pretty well for the most part.
We still need to do toString() when possible because of edge cases.
For example: stringFromXmlList1 == stringFromXmlList2 fails because the
Javascript engine does not try to convert them (correctly) to primitive values.
I’m thinking that I should implement valueOf() for XML like this:
var str:String = this.toString();
var asInt:int = parseInt(str);
if(asInt.toString() == str)
return asInt;
var asFloat:Number = parseFloat(str);
if(asFloat.toString() == str)
return asFloat;
return str;
Thi
Another error:
var resultXML:XML = XML(resString);
becomes:
var /** @type {XML} */ resultXML = org.apache.flex.utils.Language.as(resString,
XML, true);
When in fact it should become:
var /** @type {XML} */ resultXML = new XML(resString);
Do you want me to create a JIRA for this?
On Aug 4, 201
On 8/4/16, 7:22 AM, "Harbs" wrote:
>I’m not sure how to deal with this case:
>
>
>private var name:String;
>
>this.name = someXML.@Name;
>
>The above compiles to
>
>this.name = someXML.attribute('Name’);
>
>In Javascript this.name becomes an XMLList, but in Flash, the XMLList is
>implicitly con
I’m not sure how to deal with this case:
private var name:String;
this.name = someXML.@Name;
The above compiles to
this.name = someXML.attribute('Name’);
In Javascript this.name becomes an XMLList, but in Flash, the XMLList is
implicitly converted to a string.
Is it possible to make the co
25 matches
Mail list logo