Just to clarify some speculation, the syntax I proposed ({||}) was solely
inspired by Smalltalk and tempered by the parsing realities of a C-like syntax.
Any similarities to Ruby constructs are probably examples of parallel
evolution under similar environmental pressures. I suspect that designers of
other languages with C-like syntax (C# comes to mind with its () => expr
"lambda" syntax) did not have the experience or goal of using closures to
create control abstractions (which often requires passing multi-statement
closures) and so arrived at a more function-like concise closure syntax.
(more below)
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:es-discuss-
>[EMAIL PROTECTED] On Behalf Of Peter Michaux
>Sent: Monday, December 01, 2008 10:17 AM
>To: P T Withington
...
>>> // Instead of lambda (a, b, c) { ... }, why not:
>>> { |a, b, c| ... } ?
>>
>> I would rather have a more literate syntax, lest we degenerate to
>where
>> practically any comic book blasphemy is a valid program.
>
>I agree with this sentiment. The phrase "ASCII vomit" comes to mind
>and becomes a worry.
>
The use of {} as grouping syntax is inherent in the early (and irrevocable)
decision for JavaScript to use a C-like syntax rather than an Algol/Pascal or
Lisp like syntax. We already overload {} to bracket both statement blocks and
object constructors so it doesn't seem too burdensome to have another
syntactically distinct form that from some perspectives is the semantic union
of the other two forms.
JavaScript already has a concise "ASCII vomit" syntax for constructing arrays
and objects. Given the direction the language seems to be heading, having a
similar concise syntax for constructing closures seems quite appropriate.
Allen
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss