Summary of i18n ad hoc group meeting - 21st March 2011

Mark S. Miller erights at google.com
Tue Mar 22 08:24:30 PDT 2011


On Tue, Mar 22, 2011 at 8:18 AM, Nebojša Ćirić <cira at google.com> wrote:

> So if we have something like this:
>
> LocaleInfo.Collator.prototype.compare = function(a, b) {
> ...
> };
>
> How do you specify it's bound by default?
>

Two choices:

1) Don't put it on the prototype. Rather, make it part of each instance
state, don't use "this" in the function, and have the function lexically
capture all the state it needs.

2) Put it on the prototype using a binding accessor:

function makeBindingAccessorDescriptor(method) {
    return {
        get: function() { return method.bind(this); }
        set: ??, enumerable: ??, configurable: ?? // according to your
intensions
    };
}

Object.defineProperty(LocaleInfo.Collator.prototype, 'compare',
                                 makeBindingAccessorDescriptor(function(a,
b) {
    ....
}));




>
> 21. март 2011. 18.57, Mark S. Miller <erights at google.com> је написао/ла:
>
> On Mon, Mar 21, 2011 at 6:37 PM, Axel Hecht <axel at mozilla.com> wrote:
>>
>>> We had discussed that. Would it make sense to specify that coll.compare
>>> would actually be a bound method? That's one of the things that had a little
>>> "oh, no good any way we do this", as Erik wouldn't know of any example we'd
>>> follow by defining a method on an object to be bound by default.
>>>
>>
>> I'm in favor of bound by default. I don't know of any examples in ES5, but
>> it's easy to specify.
>>
>>
>>
>>>
>>> Axel
>>>
>>>
>>> On 21.03.11 18:26, Mark S. Miller wrote:
>>>
>>>>
>>>>
>>>> On Mon, Mar 21, 2011 at 5:37 PM, Nebojša Ćirić <cira at google.com
>>>> <mailto:cira at google.com>> wrote:
>>>>
>>>>    Sorry, I didn't get the difference first time around.
>>>>
>>>>    Also, current fix is to do:
>>>>
>>>>    array.sort(function(a,b) { return coll.compare(a,b); });
>>>>
>>>>
>>>> Why not
>>>>
>>>>     array.sort(coll.compare.bind(coll))
>>>>
>>>> ?
>>>>
>>>>
>>>>
>>>>
>>>>    21. март 2011. 17.31, Erik Arvidsson <erik.arvidsson at gmail.com
>>>>    <mailto:erik.arvidsson at gmail.com>> је написао/ла:
>>>>
>>>>
>>>>        On Mon, Mar 21, 2011 at 17:28, Nebojša Ćirić <cira at google.com
>>>>        <mailto:cira at google.com>> wrote:
>>>>         > Started implementation of collator in Chrome and hit a
>>>> problem:
>>>>         > var coll = locale.collator();
>>>>         > array.sort(coll.compare);
>>>>         > Compare method gets bound to the undefined or global object
>>>>        at the call
>>>>         > site. Erik mentioned that this problem will be solved in
>>>>        Harmony by passing
>>>>         > additional "this" parameter to for-each and likes. We would
>>>>        like to propose
>>>>         > extending this syntax to the sort method too.
>>>>
>>>>        Not exactly. I said that the Array methods on ES5 already pass in
>>>> an
>>>>        optional this parameter and maybe we *could* do the same for
>>>>        Array.prototype.sort in Harmony.
>>>>
>>>>         > We discussed each part of the API in order to get detailed
>>>>        parameters of
>>>>         > each constructor and method.
>>>>         > General:
>>>>         >
>>>>         > Add options property to each class that would give you actual
>>>>        value for the
>>>>         > user parameters. For example, if user asked for islamic
>>>>        calendar, and we
>>>>         > only have islamic-civil, we set calendar property to
>>>>        islamic-civil. Allows
>>>>         > developer to iterate until satisfied with the result.
>>>>         > Use Unicode identifier vs. BCP47 in the API
>>>>         >
>>>>         > Collator:
>>>>         >
>>>>         > numeric - specifies numeric sort (9 comes before 12)
>>>>         > ignoreVariants - ignore all of case, width and kana
>>>>         > ignoreWidth, ignoreCase and ignoreKana - subvariants we may
>>>>        implement to
>>>>         > fine tune the behavior
>>>>         > ignoreAccents - ignore accents
>>>>         > ignoreSymbols - ignore punctuation and symbols
>>>>         > variant - phonebook, ... - string
>>>>         >
>>>>         > NumberFormat:
>>>>         >
>>>>         > Allow patterns to specify grouping, currency symbol position
>>>>        and sign
>>>>         > location
>>>>         > Start with ICU patterns and see if they work for everybody
>>>>         > Don't support overrides for grouping separator and decimal
>>>>        point for now
>>>>         > Specify both currencySymbol and currencyCode as override
>>>>         >
>>>>         > DateTimeFormatSymbols:
>>>>         >
>>>>         > Added Era and day period methods (AM/PM)
>>>>         > Moved all methods to DateTimeFormat class
>>>>         > Remove DTFSymbols class
>>>>         >
>>>>         > DateTimeFormat:
>>>>         >
>>>>         > Specify calendar names better (move work to Unicode/LDML and
>>>>        point to their
>>>>         > document).
>>>>         > Allow short/long dateType to get value from the system or
>>>> cloud.
>>>>         > .options[skeleton] should contain best match for the given
>>>>        skeleton
>>>>         >
>>>>         > --
>>>>         > Nebojša Ćirić
>>>>         >
>>>>         > _______________________________________________
>>>>         > es-discuss mailing list
>>>>         > es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>>>>
>>>>         > https://mail.mozilla.org/listinfo/es-discuss
>>>>         >
>>>>         >
>>>>
>>>>
>>>>
>>>>        --
>>>>        erik
>>>>
>>>>
>>>>
>>>>
>>>>    --
>>>>    Nebojša Ćirić
>>>>
>>>>    _______________________________________________
>>>>    es-discuss mailing list
>>>>    es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>>>>
>>>>    https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>     Cheers,
>>>>     --MarkM
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> es-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>
>>
>>
>> --
>>     Cheers,
>>     --MarkM
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
>
> --
> Nebojša Ćirić
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110322/90afe334/attachment-0001.html>


More information about the es-discuss mailing list