You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2016/02/23 18:16:03 UTC

[FLEXJS][FALCONJX] The Date class

Hi,

This bug [1] is about the Date class.

It appears that JS uses, for example, getHour()/setHour() while AS uses
the .hour property.  How should we handle this?  Some options are:

1) Use Object.defineProperties to add get/set to Date
2) Have the compiler detect Date and generate getHour/setHour calls.

Thoughts?
-Alex

[1] https://issues.apache.org/jira/browse/FLEX-35041


Re: [FLEXJS][FALCONJX] The Date class

Posted by Andy Dufilie <an...@gmail.com>.
On Feb 23, 2016 19:34, "Alex Harui" <ah...@adobe.com> wrote:

> OK, so I'll get the compiler to map Date's properties to getX/setX calls.
>
> For Array.sort, I guess we should map it to some other function in some
> other class.  Should we generalize such a mapping or is that the only one?
>
> -Alex
>
>

These constants don't exist in JS:
Array.CASEINSENSITIVE = 1
Array.DESCENDING = 2
Array.NUMERIC = 16
Array.RETURNINDEXEDARRAY = 8
Array.UNIQUESORT = 4
int.MAX_VALUE = 2147483648
int.MIN_VALUE = -2147483648
uint.MAX_VALUE = 4294967295
uint.MIN_VALUE = 0

Array.prototype.removeAt(index) should be mapped to
Array.prototype.splice(index, 1)
Array.prototype.insertAt(index, element) should be mapped to
Array.prototype.splice(index, 0, element)

I did not notice any others in Date/Number/String.

Andy

Re: [FLEXJS][FALCONJX] The Date class

Posted by Alex Harui <ah...@adobe.com>.
OK, so I'll get the compiler to map Date's properties to getX/setX calls.

For Array.sort, I guess we should map it to some other function in some
other class.  Should we generalize such a mapping or is that the only one?

-Alex

On 2/23/16, 1:31 PM, "Andy Dufilie" <an...@gmail.com> wrote:

>You're right, it would be great to have these things fixed automatically.
>I
>wouldn't want built-in types to be modified, though. My team recently
>passed up one library for another because it was modifying the Date
>prototype.
>
>Andy
>
>On Tue, Feb 23, 2016 at 3:53 PM, Alex Harui <ah...@adobe.com> wrote:
>
>> A warning for Array.sort() might be the right answer, although I would
>>be
>> tempted to cross-compile it to something like Array.ActionScriptSort()
>>and
>> actually implement what it does in AS.
>>
>> For Date, I think folks will expect properties like .hour to work.  The
>> feedback I think I'm hearing is that folks want the lowest barrier to
>> migration that we can give them.  We may never get it to zero, but every
>> time they have to change their code it gives them a reason to consider
>> other frameworks.
>>
>> Another option that doesn't involve compiler changes is that we create a
>> bead that adds the getters and setters to Date so folks can opt-in.  I
>> don't think I want to try to override Array.sort, so I'd still have
>> cross-compiler generate a call to a differently named function.
>>
>> -Alex
>>
>> On 2/23/16, 11:44 AM, "Peter Ent" <pe...@adobe.com> wrote:
>>
>> >I have to agree with Andy about issuing warnings.
>> >
>> >We could make Date an exception and the compiler sees .hour and
>>translates
>> >that to .getHours() for the JS code as Alex suggests. That seems like
>>its
>> >pretty straightforward but anything not as obvious just get flagged.
>> >
>> >My 2 cents,
>> >Peter Ent
>> >Adobe Systems/Apache Flex Project
>> >
>> >On 2/23/16, 1:44 PM, "Andy Dufilie" <an...@gmail.com> wrote:
>> >
>> >>AS has getHours() and setHours() too.  If the code is updated to use
>> >>those
>> >>it should work.
>> >>Date is not the only class that has differences - Array.sort() is not
>>the
>> >>same in AS and JS.
>> >>I think the most the compiler should do is provide a warning when
>>using
>> >>known AS features that do not exist in JS, because some things can't
>> >>easily
>> >>be translated.
>> >>
>> >>Andy
>> >>
>> >>On Tue, Feb 23, 2016 at 12:16 PM, Alex Harui <ah...@adobe.com> wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> This bug [1] is about the Date class.
>> >>>
>> >>> It appears that JS uses, for example, getHour()/setHour() while AS
>>uses
>> >>> the .hour property.  How should we handle this?  Some options are:
>> >>>
>> >>> 1) Use Object.defineProperties to add get/set to Date
>> >>> 2) Have the compiler detect Date and generate getHour/setHour calls.
>> >>>
>> >>> Thoughts?
>> >>> -Alex
>> >>>
>> >>> [1] https://issues.apache.org/jira/browse/FLEX-35041
>> >>>
>> >>>
>> >
>>
>>


Re: [FLEXJS][FALCONJX] The Date class

Posted by Andy Dufilie <an...@gmail.com>.
You're right, it would be great to have these things fixed automatically. I
wouldn't want built-in types to be modified, though. My team recently
passed up one library for another because it was modifying the Date
prototype.

Andy

On Tue, Feb 23, 2016 at 3:53 PM, Alex Harui <ah...@adobe.com> wrote:

> A warning for Array.sort() might be the right answer, although I would be
> tempted to cross-compile it to something like Array.ActionScriptSort() and
> actually implement what it does in AS.
>
> For Date, I think folks will expect properties like .hour to work.  The
> feedback I think I'm hearing is that folks want the lowest barrier to
> migration that we can give them.  We may never get it to zero, but every
> time they have to change their code it gives them a reason to consider
> other frameworks.
>
> Another option that doesn't involve compiler changes is that we create a
> bead that adds the getters and setters to Date so folks can opt-in.  I
> don't think I want to try to override Array.sort, so I'd still have
> cross-compiler generate a call to a differently named function.
>
> -Alex
>
> On 2/23/16, 11:44 AM, "Peter Ent" <pe...@adobe.com> wrote:
>
> >I have to agree with Andy about issuing warnings.
> >
> >We could make Date an exception and the compiler sees .hour and translates
> >that to .getHours() for the JS code as Alex suggests. That seems like its
> >pretty straightforward but anything not as obvious just get flagged.
> >
> >My 2 cents,
> >Peter Ent
> >Adobe Systems/Apache Flex Project
> >
> >On 2/23/16, 1:44 PM, "Andy Dufilie" <an...@gmail.com> wrote:
> >
> >>AS has getHours() and setHours() too.  If the code is updated to use
> >>those
> >>it should work.
> >>Date is not the only class that has differences - Array.sort() is not the
> >>same in AS and JS.
> >>I think the most the compiler should do is provide a warning when using
> >>known AS features that do not exist in JS, because some things can't
> >>easily
> >>be translated.
> >>
> >>Andy
> >>
> >>On Tue, Feb 23, 2016 at 12:16 PM, Alex Harui <ah...@adobe.com> wrote:
> >>
> >>> Hi,
> >>>
> >>> This bug [1] is about the Date class.
> >>>
> >>> It appears that JS uses, for example, getHour()/setHour() while AS uses
> >>> the .hour property.  How should we handle this?  Some options are:
> >>>
> >>> 1) Use Object.defineProperties to add get/set to Date
> >>> 2) Have the compiler detect Date and generate getHour/setHour calls.
> >>>
> >>> Thoughts?
> >>> -Alex
> >>>
> >>> [1] https://issues.apache.org/jira/browse/FLEX-35041
> >>>
> >>>
> >
>
>

Re: [FLEXJS][FALCONJX] The Date class

Posted by Alex Harui <ah...@adobe.com>.
A warning for Array.sort() might be the right answer, although I would be
tempted to cross-compile it to something like Array.ActionScriptSort() and
actually implement what it does in AS.

For Date, I think folks will expect properties like .hour to work.  The
feedback I think I'm hearing is that folks want the lowest barrier to
migration that we can give them.  We may never get it to zero, but every
time they have to change their code it gives them a reason to consider
other frameworks.

Another option that doesn't involve compiler changes is that we create a
bead that adds the getters and setters to Date so folks can opt-in.  I
don't think I want to try to override Array.sort, so I'd still have
cross-compiler generate a call to a differently named function.

-Alex

On 2/23/16, 11:44 AM, "Peter Ent" <pe...@adobe.com> wrote:

>I have to agree with Andy about issuing warnings.
>
>We could make Date an exception and the compiler sees .hour and translates
>that to .getHours() for the JS code as Alex suggests. That seems like its
>pretty straightforward but anything not as obvious just get flagged.
>
>My 2 cents,
>Peter Ent
>Adobe Systems/Apache Flex Project
>
>On 2/23/16, 1:44 PM, "Andy Dufilie" <an...@gmail.com> wrote:
>
>>AS has getHours() and setHours() too.  If the code is updated to use
>>those
>>it should work.
>>Date is not the only class that has differences - Array.sort() is not the
>>same in AS and JS.
>>I think the most the compiler should do is provide a warning when using
>>known AS features that do not exist in JS, because some things can't
>>easily
>>be translated.
>>
>>Andy
>>
>>On Tue, Feb 23, 2016 at 12:16 PM, Alex Harui <ah...@adobe.com> wrote:
>>
>>> Hi,
>>>
>>> This bug [1] is about the Date class.
>>>
>>> It appears that JS uses, for example, getHour()/setHour() while AS uses
>>> the .hour property.  How should we handle this?  Some options are:
>>>
>>> 1) Use Object.defineProperties to add get/set to Date
>>> 2) Have the compiler detect Date and generate getHour/setHour calls.
>>>
>>> Thoughts?
>>> -Alex
>>>
>>> [1] https://issues.apache.org/jira/browse/FLEX-35041
>>>
>>>
>


Re: [FLEXJS][FALCONJX] The Date class

Posted by Peter Ent <pe...@adobe.com>.
I have to agree with Andy about issuing warnings.

We could make Date an exception and the compiler sees .hour and translates
that to .getHours() for the JS code as Alex suggests. That seems like its
pretty straightforward but anything not as obvious just get flagged.

My 2 cents,
Peter Ent
Adobe Systems/Apache Flex Project

On 2/23/16, 1:44 PM, "Andy Dufilie" <an...@gmail.com> wrote:

>AS has getHours() and setHours() too.  If the code is updated to use those
>it should work.
>Date is not the only class that has differences - Array.sort() is not the
>same in AS and JS.
>I think the most the compiler should do is provide a warning when using
>known AS features that do not exist in JS, because some things can't
>easily
>be translated.
>
>Andy
>
>On Tue, Feb 23, 2016 at 12:16 PM, Alex Harui <ah...@adobe.com> wrote:
>
>> Hi,
>>
>> This bug [1] is about the Date class.
>>
>> It appears that JS uses, for example, getHour()/setHour() while AS uses
>> the .hour property.  How should we handle this?  Some options are:
>>
>> 1) Use Object.defineProperties to add get/set to Date
>> 2) Have the compiler detect Date and generate getHour/setHour calls.
>>
>> Thoughts?
>> -Alex
>>
>> [1] https://issues.apache.org/jira/browse/FLEX-35041
>>
>>


Re: [FLEXJS][FALCONJX] The Date class

Posted by Andy Dufilie <an...@gmail.com>.
AS has getHours() and setHours() too.  If the code is updated to use those
it should work.
Date is not the only class that has differences - Array.sort() is not the
same in AS and JS.
I think the most the compiler should do is provide a warning when using
known AS features that do not exist in JS, because some things can't easily
be translated.

Andy

On Tue, Feb 23, 2016 at 12:16 PM, Alex Harui <ah...@adobe.com> wrote:

> Hi,
>
> This bug [1] is about the Date class.
>
> It appears that JS uses, for example, getHour()/setHour() while AS uses
> the .hour property.  How should we handle this?  Some options are:
>
> 1) Use Object.defineProperties to add get/set to Date
> 2) Have the compiler detect Date and generate getHour/setHour calls.
>
> Thoughts?
> -Alex
>
> [1] https://issues.apache.org/jira/browse/FLEX-35041
>
>