You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2017/03/09 17:37:50 UTC
[FalconJX] casting idea
It’s really a drag to constantly put in @flexjsignorecoercion every time I’m using “as” to make the compiler happy. 99% of the time I’m not interested in Language.as being added to the code.
Here’s a thought: Can we add a new operator for non-essential casts?
Something like this:
var foo:Thing = item as Thing would cross-compiler to var foo = Language.as(item,Thing)
but var foo:Thing = item asa Thing would just compile as “var foo = thing;” (and on the SWF side, “asa” would become a regular “as”).
Thoughts?
Harbs
Re: [FalconJX] casting idea
Posted by Harbs <ha...@gmail.com>.
Huh. I did not know about @flexjsemitcoercion.
Good to know!
> On Mar 9, 2017, at 8:51 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
>
> On 3/9/17, 10:44 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> Umm... I guess I was not thinking clearly. (exhaustion can do that…) ;-)
>> I was thinking that the casting happens when compiling the app, but
>> that’s not true as the js from the library is pre-compiled.
>>
>> However, I don’t think I can globally disable “as” in TLF, and I don’t
>> think we can do that in the FlexJS SDK libs either.
>
> But we can turn it on where we need it. Basically, -skipAsCoercions and
> @flexjsemitcoercion assume you don't want 99% of "as" usage and will
> annotate where you need it. The default assumes you need it and will
> @flexjsignorecoercion where you don't need it. The framework could
> probably get away with assuming we don't need it.
>
> HTH,
> -Alex
>
Re: [FalconJX] casting idea
Posted by Alex Harui <ah...@adobe.com>.
On 3/9/17, 10:44 AM, "Harbs" <ha...@gmail.com> wrote:
>Umm... I guess I was not thinking clearly. (exhaustion can do that…) ;-)
>I was thinking that the casting happens when compiling the app, but
>that’s not true as the js from the library is pre-compiled.
>
>However, I don’t think I can globally disable “as” in TLF, and I don’t
>think we can do that in the FlexJS SDK libs either.
But we can turn it on where we need it. Basically, -skipAsCoercions and
@flexjsemitcoercion assume you don't want 99% of "as" usage and will
annotate where you need it. The default assumes you need it and will
@flexjsignorecoercion where you don't need it. The framework could
probably get away with assuming we don't need it.
HTH,
-Alex
Re: [FalconJX] casting idea
Posted by Harbs <ha...@gmail.com>.
Umm... I guess I was not thinking clearly. (exhaustion can do that…) ;-) I was thinking that the casting happens when compiling the app, but that’s not true as the js from the library is pre-compiled.
However, I don’t think I can globally disable “as” in TLF, and I don’t think we can do that in the FlexJS SDK libs either.
> On Mar 9, 2017, at 8:30 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
>
> On 3/9/17, 10:22 AM, "Harbs" <ha...@gmail.com> wrote:
>
>>> You can turn off all "as" output in the cross-compile via
>>> -skipAsCoercions
>>
>> Only if you are compiling your own app — and you never rely on “as”
>> casting.
>>
>> That doesn’t help if you are writing a library.
>
> I guess I don't understand. IMO, either your code needs coercion at
> runtime or it doesn't. Why is a Library different from an App in this
> case?
>
> Thanks,
> -Alex
>
Re: [FalconJX] casting idea
Posted by Alex Harui <ah...@adobe.com>.
On 3/9/17, 10:22 AM, "Harbs" <ha...@gmail.com> wrote:
>> You can turn off all "as" output in the cross-compile via
>>-skipAsCoercions
>
>Only if you are compiling your own app — and you never rely on “as”
>casting.
>
>That doesn’t help if you are writing a library.
I guess I don't understand. IMO, either your code needs coercion at
runtime or it doesn't. Why is a Library different from an App in this
case?
Thanks,
-Alex
Re: [FalconJX] casting idea
Posted by Harbs <ha...@gmail.com>.
> You can turn off all "as" output in the cross-compile via -skipAsCoercions
Only if you are compiling your own app — and you never rely on “as” casting.
That doesn’t help if you are writing a library.
> Nor do I want to be the person who implements it.
Can’t say I blame you there… ;-)
> On Mar 9, 2017, at 8:14 PM, Alex Harui <ah...@adobe.com> wrote:
>
> You can turn off all "as" output in the cross-compile via -skipAsCoercions
> compiler option. Then you shouldn't need @flexjsignorecoercion. And then
> you use @flexjsemitcoercion where you actually need it.
>
> Introducing new keywords makes me nervous, but I am not opposed to it.
> Nor do I want to be the person who implements it.
>
> My 2 cents,
> -Alex
>
> On 3/9/17, 9:37 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> It’s really a drag to constantly put in @flexjsignorecoercion every time
>> I’m using “as” to make the compiler happy. 99% of the time I’m not
>> interested in Language.as being added to the code.
>>
>> Here’s a thought: Can we add a new operator for non-essential casts?
>>
>> Something like this:
>>
>> var foo:Thing = item as Thing would cross-compiler to var foo =
>> Language.as(item,Thing)
>>
>> but var foo:Thing = item asa Thing would just compile as “var foo =
>> thing;” (and on the SWF side, “asa” would become a regular “as”).
>>
>> Thoughts?
>>
>> Harbs
>
Re: [FalconJX] casting idea
Posted by Alex Harui <ah...@adobe.com>.
You can turn off all "as" output in the cross-compile via -skipAsCoercions
compiler option. Then you shouldn't need @flexjsignorecoercion. And then
you use @flexjsemitcoercion where you actually need it.
Introducing new keywords makes me nervous, but I am not opposed to it.
Nor do I want to be the person who implements it.
My 2 cents,
-Alex
On 3/9/17, 9:37 AM, "Harbs" <ha...@gmail.com> wrote:
>It’s really a drag to constantly put in @flexjsignorecoercion every time
>I’m using “as” to make the compiler happy. 99% of the time I’m not
>interested in Language.as being added to the code.
>
>Here’s a thought: Can we add a new operator for non-essential casts?
>
>Something like this:
>
>var foo:Thing = item as Thing would cross-compiler to var foo =
>Language.as(item,Thing)
>
>but var foo:Thing = item asa Thing would just compile as “var foo =
>thing;” (and on the SWF side, “asa” would become a regular “as”).
>
>Thoughts?
>
>Harbs