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 gensym via $tmp):
foo.bar()<==> do {let $tmp = foo.bar; $tmp.call(foo)}
Now use ?. used instead of dot. Either the equivalence breaks:
foo?.bar()<!=> do {let $tmp = foo?.bar; $tmp.call(foo)}
Why is it important that this equivalence holds for . and ?.
Equivalences are not sacred but they are informative and sometimes
normative (as in, a refactoring norm exists in the world).
We already have other places using references where similar refactoring
aren't equivalent:
typeof foo<!=> do(let $tmp = foo /*Reference error if foo unresolvable)
*/; typeof $tmp)
That's right, and that is considered a botch not to imitate.The fact
that typeof x == "function" testing is so long-winded is indeed one of
the motivations for ?(.
In particular, I'm pretty sure that this refactoring hazard is not going to be
as significant as the
foo?.bar() //oops I'm really think foo?.bar?()
hazard
CoffeeScript has years of use, and this is not something that has caused
confusion (ask @jashkenas, see github issues).
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss