More on this

So I showed my confusing problem detailed in this last post to Dave Herman, who after an initial surprise, said that this was probably due to ES4 expansions method binding — that is, o.f sometimes closes over this, but sometimes not.

It doesn’t work in Opera or IE — they return false for both function calls — but it seems that if they implement ES4, the first call will eventually return true. That seems terrible to me — it was so surprising! It also makes it a little difficult to use JavaScript itself as a compiler representation, since you can’t use A-normal form if let-abstraction doesn’t work. Never mind that programmers (read: I) use let-abstraction to break up complicated expressions when debugging, and so this change in behavior will only confuse matters more.

Dave pointed out that in trade-offs between consistency and convenience, the latter sometimes wins, particularly when changes affect thousands and millions of people. But it’s not clear to me how convenient this is; it’s a tiny shortcut for those who know about it, but it’s very fragile. I’d liken it to operator precedences: in only a few cases do people take advantage of the ordering, so arithmetic expressions are generally just written out with parentheses for clarity.

* Filed by Michael Greenberg on 2007-03-26 at 3:28pm under Programming Languages

a weasel in a hat

2 Responses to “More on this

  1. April 18th, 2007 | 2:12pm

    OpenLaszlo has an LzDelegate class that takes an instance and a method name (as a string) - it’s essentially a poor man’s closure. I always delegates were an answer to some vagary in our class system, but it turns out that they have a purpose - don’t depend on this!

  2. April 18th, 2007 | 2:15pm

    Bah—the blog software ate my <code> in a way I didn’t intend.

Leave a reply

Please submit only once. Comments are moderated and will not appear immediately.