At the TC39 meeting two weeks ago in Kona, we had a brief bikeshedding
discussion about lambda syntax and why it matters. Observation: blocks
in Smalltalk being lightweight means users don't mind writing them for
control abstractions, compared to JS functions in ES3. In Smalltalk,
ignoring JS, it's hard to beat [ and ] as overhead, although one must
count the message selector and its punctuation too.
Allen Wirfs-Brock put his proposal, which will not shock you who know
Smalltalk or Allen, on the whiteboard:
// Instead of lambda (a, b, c) { ... }, why not:
{ |a, b, c| ... } ?
I then started to write an example of return to label, and in need of
a nested lambda, got stuck for a split second trying to write
function^H^H^H^H^H^H^H^lambda. After thinking 0.3 more seconds I then
said "I will use Allen's proposed syntax". Pure win, readers and the
writer (me) agreed.
I think someone proposed pretty much the same syntax here on es*-
discuss within the last two years, but I can't find that message at
the moment.
Bikeshed color is secondary to semantics, but lambda conciseness does
matter. I think Allen's homage to Smalltalk in JS wins. Every time I
reach for more verbose syntax my hand steers back to those ||
delimiters.
Am I an old Smalltalk fan? Sure, I have Byte magazine with the
balloons on the cover still (in a box somewhere; mildewed, sadly). I'm
the C hacker who took the "make it look like Java" orders and made it
look like C with some awk, Self, Scheme, and even HyperCard
(HyperTalk, actually) influences.
Eclecticism is not an end, but it could be a means to a better end
than a cramped non-eclectic grammar, if the deeper reasons for concise
lambda syntax are sound and valid. Syntax is for users, it must be
usably sweet. It's not all about theoretical completeness and
minimality.
Anyway, we need a fun weekend thread, and everyone loves syntax.
Comments? Huzzahs? The latter go to Allen. Go nuts.
/be
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss