Re: Would some like Object.inspect(myObj) be useful?

2012-06-19 Thread Tom Van Cutsem
2012/6/14 Allen Wirfs-Brock al...@wirfs-brock.com On Jun 14, 2012, at 10:52 AM, Brendan Eich wrote: ... Thanks. Any reason this wasn't included in ES5 that you recall? Minimalism. Object.* wasn't intended to be a comprehensive reflection library, just a set of essential primitives that

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: This proposal augments the default operator http://wiki.ecmascript.org/doku.php?id=strawman:default_operator by adding syntax to avoid accessing a missing property, specifically |?.| for getting and setting a property from a reference base that might be |undefined| or

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread David Bruant
What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would become: let greedy = silent obj.hints.greedy; The semantic would be exactly the same. The syntax is up to debate. Specifically, it would be nice to be able to

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Hemanth H.M
As there is no keyword as 'or' so far, does something like *x = x.value or 5 *sound better? On Tue, Jun 19, 2012 at 3:00 PM, David Bruant bruan...@gmail.com wrote: What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would

Re: Existential operator

2012-06-19 Thread David Bruant
Le 19/06/2012 11:40, Hemanth H.M a écrit : As there is no keyword as 'or' so far, does something like *x = x.value or 5 *sound better? I realize I gave examples with default values in case of error, but it doesn't have to be the case. Specifically in let greedy = try obj.hints.greedy an

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Alex Russell
On Jun 11, 2012, at 11:46 AM, David Bruant wrote: Hi, Le 11/06/2012 12:30, Hemanth H.M a écrit : [].forEach.call(NodeList,function(elm) {}) why that? Why not treat it like an [] ? I've written a section on MDN specifically a while ago to answer that very question:

Re: Why not NodeList#forEach :\?

2012-06-19 Thread David Bruant
Le 19/06/2012 14:11, Alex Russell a écrit : On Jun 11, 2012, at 11:46 AM, David Bruant wrote: Hi, Le 11/06/2012 12:30, Hemanth H.M a écrit : [].forEach.call(NodeList,function(elm) {}) why that? Why not treat it like an [] ? I've written a section on MDN specifically a while ago to answer

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Rick Waldron
On Tuesday, June 19, 2012 at 8:29 AM, David Bruant wrote: Le 19/06/2012 14:11, Alex Russell a écrit : On Jun 11, 2012, at 11:46 AM, David Bruant wrote: Hi, Le 11/06/2012 12:30, Hemanth H.M a écrit : [].forEach.call(NodeList,function(elm) {}) why that? Why not treat it

Re: Why not NodeList#forEach :\?

2012-06-19 Thread 程劭非
I guess we can try to push Web IDL to do this. 2012/6/11 Hemanth H.M hemanth...@gmail.com: [].forEach.call(NodeList,function(elm) {}) why that? Why not treat it like an [] ? -- 'I am what I am because of who we all are' h3manth.com -- Hemanth HM

Re: Internationalization: Normalization and canonical equivalence in string comparison

2012-06-19 Thread Rick Waldron
On Tue, Jun 19, 2012 at 12:36 AM, Norbert Lindenberg ecmascr...@norbertlindenberg.com wrote: The ECMAScript Internationalization API Specification currently has normalization as an optional feature in collation. However, it requires that the compare function return 0 when comparing Strings

Re: Internationalization: Normalization and canonical equivalence in string comparison

2012-06-19 Thread Norbert Lindenberg
The test is at http://norbertlindenberg.com/ecmascript/ESTest.html (and .js). The strings I used are: [o\u0308, ö], [ä\u0323, a\u0323\u0308], // requires reordering [a\u0308\u0323, a\u0323\u0308], // requires reordering [ạ\u0308, a\u0323\u0308], [ä\u0306, a\u0308\u0306], [ă\u0308, a\u0306\u0308],

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 5:29 AM, David Bruant wrote: Le 19/06/2012 14:11, Alex Russell a écrit : ... is to give us a chance to fix this (among other) errors in DOM's design. Yes, it's up to DOM to fix it, but we need ES to adopt things like Allen's Object Model Reformation to help enable

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Erik Arvidsson
On Tue, Jun 19, 2012 at 6:42 AM, 程劭非 csf...@gmail.com wrote: I guess we can try to push Web IDL to do this. WebIDL provides [ArrayClass] and DOM4 make NodeLists ArrayClass. This means that NodeLists have Array.prototype on its prototype chain. We tried to make this change in WebKit but it

Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Erik Arvidsson
On Tue, Jun 19, 2012 at 8:37 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: Actual API design is probably an orthogonal issue.  What the Object Model Reformation proposal (which is probably better understood by its subtitle Decoupling [ ] and Property Access) does is permit the existing

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 12:44 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: This proposal augments the default operator http://wiki.ecmascript.org/doku.php?id=strawman:default_operator by adding syntax to avoid accessing a missing property, specifically |?.| for getting and setting a

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Herby Vojčík
Allen Wirfs-Brock wrote: On Jun 19, 2012, at 12:44 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: This proposal augments the default operatorhttp://wiki.ecmascript.org/doku.php?id=strawman:default_operator by adding syntax to avoid accessing a missing property, specifically |?.| for

Re: Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Hemanth H.M
Hoping to see that day soon! :) On Tue, Jun 19, 2012 at 10:01 PM, Erik Arvidsson erik.arvids...@gmail.comwrote: On Tue, Jun 19, 2012 at 8:37 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: Actual API design is probably an orthogonal issue. What the Object Model Reformation proposal

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Aymeric Vitte
When I made that one : https://github.com/Ayms/node-dom it was supposed to be a fast and minimal implementation of the DOM, so it works in almost all real cases and do not crash in other situations. The result is not bad but not as fast as expected neither minimal. Not minimal because I had

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 2:30 AM, David Bruant wrote: What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would become: let greedy = silent obj.hints.greedy; A hazard with this approach is that it could silence a

Re: Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Brendan Eich
Erik Arvidsson wrote: document.forms[0].bar instead of document.forms[0]['bar'] frames.foo instead of frames['foo'] How does Allen's strawman preclude these? You can have .foo and .bar by the usual means, as properties (lazy if proxied). You can alias indexes to them using @elementGet and

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
David Bruant wrote: What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would become: let greedy = silent obj.hints.greedy; Ignoring exact syntax, I don't think we want more general throwing suppression. The goal with

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: I still stand by my alternative semantics as being a way to address the more important use case without have ?() No, the basis cases differ and that is a bug in your alternative. foo?.bar means take bar from foo or undefined if foo == null. foo?.bar() means take bar

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Brendan Eich wrote: Allen Wirfs-Brock wrote: I still stand by my alternative semantics as being a way to address the more important use case without have ?() No, the basis cases differ and that is a bug in your alternative. foo?.bar means take bar from foo or undefined if foo == null.

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
Sorry -- an old inbox filter caused me to miss this... There were a couple of questions asked in the thread, but I think it might be helpful to summarize the overall rationale first. The existential operator in CoffeeScript (?) is intended to make it easier to ask questions about whether values

Re: Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Erik Arvidsson
On Tue, Jun 19, 2012 at 10:12 AM, Brendan Eich bren...@mozilla.org wrote: How does Allen's strawman preclude these? You can have .foo and .bar by the usual means, as properties (lazy if proxied). You can alias indexes to them using @elementGet and @elementSet if those hooks are invoked for any

Re: Internationalization: Normalization and canonical equivalence in string comparison

2012-06-19 Thread Gillam, Richard
Norbert-- The ECMAScript Internationalization API Specification currently has normalization as an optional feature in collation. However, it requires that the compare function return 0 when comparing Strings that are considered canonically equivalent by the Unicode standard. Canonical

Re: Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 10:34 AM, Erik Arvidsson wrote: On Tue, Jun 19, 2012 at 10:12 AM, Brendan Eich bren...@mozilla.org wrote: How does Allen's strawman preclude these? You can have .foo and .bar by the usual means, as properties (lazy if proxied). You can alias indexes to them using

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Another problem with your alternative: either it breaks a refactoring equivalence. Let == be equivalence for a program fragment, and != be inequivalence. Then we have in JS today extended with do expressions (and gensym via $tmp): foo.bar() == do {let $tmp = foo.bar; $tmp.call(foo)} Now

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Brendan Eich wrote: Another problem with your alternative: either it breaks a refactoring equivalence. ... or it leaks maybe-Reference type values into the language. /be ___ es-discuss mailing list es-discuss@mozilla.org

Re: Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Erik Arvidsson
On Tue, Jun 19, 2012 at 10:45 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: There are various differences between @elementGet and @elementSet and proxy get/set handlers.  One is that the index value isn't coerced to a string before being passed to @elementGet/@elementSet That's a good

Re: Decoupling [ ] and Property Access and the DOM (Was: Why not NodeList#forEach :\?)

2012-06-19 Thread Brendan Eich
Erik Arvidsson wrote: On Tue, Jun 19, 2012 at 10:45 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: There are various differences between @elementGet and @elementSet and proxy get/set handlers. One is that the index value isn't coerced to a string before being passed to

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Jeremy Ashkenas wrote: Everywhere else in the language, `?` means existence (not null or undefined) -- but when used to call a function, the check ensures that the value is callable as well. In a DWIM sense, this makes sense, because the only things you'd ever want to try to call in

RE: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Domenic Denicola
What struck me from Jeremy's explanation was the uniformity of CoffeeScript's ? operator (modulo the small issue he mentioned for function calls). It seems to combine the currently-strawman'ed ??/??= and ?. into one very simple semantic. What about adopting ?? as CoffeeScript's ? operator?

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Herby Vojčík
Brendan Eich wrote: Jeremy Ashkenas wrote: Everywhere else in the language, `?` means existence (not null or undefined) -- but when used to call a function, the check ensures that the value is callable as well. In a DWIM sense, this makes sense, because the only things you'd ever want to try

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
That's possible but it is a bit ugly, isn't it? Also, as dherman observed, ?. and variations are different from defaulting, in one point of view. That is, avoiding dereferencing a value that does not coerce to object is the purpose of ?. but not necessarily of ??= (or || as used for

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Herby Vojčík wrote: Will you include options.success?.[index] then, too? I wasn't planning on it. CoffeeScript does not have any such thing (spelling it ?[ would be hard in CS too, due to array literals). Could add it in the future, trying not to overdo the strawman at this point. YAGNI and

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
On Tue, Jun 19, 2012 at 2:59 PM, Brendan Eich bren...@mozilla.org wrote: Herby Vojčík wrote: Will you include options.success?.[index] then, too? I wasn't planning on it. CoffeeScript does not have any such thing (spelling it ?[ would be hard in CS too, due to array literals). Could add

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 10:31 AM, Brendan Eich wrote: Brendan Eich wrote: Allen Wirfs-Brock wrote: I still stand by my alternative semantics as being a way to address the more important use case without have ?() No, the basis cases differ and that is a bug in your alternative. foo?.bar

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Jeremy Ashkenas wrote: On Tue, Jun 19, 2012 at 2:59 PM, Brendan Eich bren...@mozilla.org mailto:bren...@mozilla.org wrote: Herby Vojčík wrote: Will you include options.success?.[index] then, too? I wasn't planning on it. CoffeeScript does not have any such thing

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: I don't agree, probably because I'm look at ?. as an operator that evaluates to a special kind of Reference. That your alternative off-by-one in its basis case is bad enough -- it creates two error suppression points from one syntactic extension-point, it will hide

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 10:50 AM, Brendan Eich wrote: Another problem with your alternative: either it breaks a refactoring equivalence. Let == be equivalence for a program fragment, and != be inequivalence. Then we have in JS today extended with do expressions (and gensym via $tmp):

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Brendan Eich wrote: Worse, instead of leaking an observable ConditionalReference (whew!), you've opted to break the equivalence between foo.bar() and %tmp = foo.bar; %tmp.call(foo) for the case where . is replaced by ?. -- in this case your proposal does not throw while the expansion does.

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 12:26 PM, Brendan Eich wrote: Brendan Eich wrote: Worse, instead of leaking an observable ConditionalReference (whew!), you've opted to break the equivalence between foo.bar() and %tmp = foo.bar; %tmp.call(foo) for the case where . is replaced by ?. -- in this case your

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brandon Benvie
Is it possible to do something like foo.bar?:(foo, args) Basically a ternary that allows an empty component, and can tell the future (whether the other result is callable) ___ es-discuss mailing list es-discuss@mozilla.org

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
On Tue, Jun 19, 2012 at 3:33 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: foo.bar?(args) == foo.bar?.call(foo, args) fun?(args) == fun?.call(undefined, args) How are these equivalent? Won't fun?.call evaluate to undefined if fun is undefined and undefined(undefined,args) will

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 12:37 PM, Jeremy Ashkenas wrote: On Tue, Jun 19, 2012 at 3:33 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: foo.bar?(args) == foo.bar?.call(foo, args) fun?(args) == fun?.call(undefined, args) How are these equivalent? Won't fun?.call evaluate to

Re: Why not NodeList#forEach :\?

2012-06-19 Thread David Bruant
Le 19/06/2012 18:21, Erik Arvidsson a écrit : On Tue, Jun 19, 2012 at 6:42 AM, 程劭非 csf...@gmail.com wrote: I guess we can try to push Web IDL to do this. WebIDL provides [ArrayClass] and DOM4 make NodeLists ArrayClass. This means that NodeLists have Array.prototype on its prototype chain.

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
On Tue, Jun 19, 2012 at 4:35 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: Ah, interesting...so this is actually close to what I was advocating for this particular case. However, if I now understand correctly you are saying that fun?.call() produces undefined if fun is

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 2:15 PM, Jeremy Ashkenas wrote: On Tue, Jun 19, 2012 at 4:35 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: ... Ha ha, loose equality strikes again! It's actually guarding for both null and undefined. It's the only place that CoffeeScript purposefully uses the

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Erik Arvidsson
On Tue, Jun 19, 2012 at 1:55 PM, David Bruant bruan...@gmail.com wrote: Le 19/06/2012 18:21, Erik Arvidsson a écrit : On Tue, Jun 19, 2012 at 6:42 AM, 程劭非 csf...@gmail.com wrote: I guess we can try to push Web IDL to do this. WebIDL provides [ArrayClass] and DOM4 make NodeLists ArrayClass.

Re: Why not NodeList#forEach :\?

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 3:20 PM, Erik Arvidsson wrote: On Tue, Jun 19, 2012 at 1:55 PM, David Bruant bruan...@gmail.com wrote: Le 19/06/2012 18:21, Erik Arvidsson a écrit : On Tue, Jun 19, 2012 at 6:42 AM, 程劭非 csf...@gmail.com wrote: I guess we can try to push Web IDL to do this. WebIDL

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: On Jun 19, 2012, at 10:50 AM, Brendan Eich wrote: Another problem with your alternative: either it breaks a refactoring equivalence. Let== be equivalence for a program fragment, and!= be inequivalence. Then we have in JS today extended with do expressions (and

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Indeed I did not spec this in http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator#semantics -- one step at a time. Also I'm not sure how the indefinite soak will fly with others on TC39. Allen, I agree if we do make a soak and don't spec it as CoffeeScript realizes it (by

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Aymeric Vitte
Complement for my last sentence : if you are using ?. it means that you don't know if the thing does exist, then you are probably waiting for it to exist (asynchronous environments for example), then once you get it, it is very unlikely that you call it right away, I would like to see some