On 26.07.2010 4:16, Sam Ruby wrote:
On Sun, Jul 25, 2010 at 7:57 PM, Maciej Stachowiak<[email protected]>  wrote:
Good point about the escaping hazard. I think # may look funny to people
because it is a "noisy" symbol and also because it is a comment delimiter in
many languages. Two other characters totally disallowed in the syntax are @
and `, I wonder if either of those would be more visually pleasing:
[0, 1, 2, 3].map( #(x) {x * x} )
[0, 1, 2, 3].map( `(x) {x * x} )
[0, 1, 2, 3].map( @(x) {x * x} )
I also wonder if using a strictly binary operator might be workable without
creating syntax ambiguities:
[0, 1, 2, 3].map( ^(x) {x * x} )
[0, 1, 2, 3].map( *(x) {x * x} )
[0, 1, 2, 3].map( %(x) {x * x} )
The ruby syntax for the above is as follows:

[0,1,2,3].map {|x| x*x}

(try it in 'irb' to see what I mean)

While I don't believe that would fly here, perhaps adding parens
around the function would:

[0,1,2,3].map({|x| x*x})


In JS |x| can be placed outside, and then some special name won't be needed at all:

[1, 2, 3].map((x) {x * x}).

This exactly how it's used in CoffeeScript. But in contrast with Coffee, JS has obligatory parens, so (( looks not so good. But really, this syntax is nice:

withFoo: (x) -> x* x   -- define a function

[1, 2, 3].map (x) -> x * x -- pass an anonymous "funarg" to map

Or the same:

[1, 2, 3].map withFoo -- it sounds! And declaratively looks nice.

Will Harmony consider to call a function without parens -- to provide ability of more declarative in some cases?

Dmitry.

- Sam Ruby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to