Dmitry A. Soshnikov:
> 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}).

Wouldn’t this have the same problem that Oliver mentioned?  Only in this
case the ambiguity would be whether the “(x)” is a parenthesized
expression or the introduction of the anonymous function.

Sam Ruby:
> [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})

I think having the braces on the outside would help with the
aforementioned problem.  The vertical bars don’t particularly grab me
(not being a Rubyist), but this does:

  [0, 1, 2, 3].map({ x => x * x }); // optionally { (x) => x * x }?

  function mapPairs(o, f) {
    for (var p in o) {
      f(p, o[p]);
    }
  }

  mapPairs(someObject, { (a, b) => a + '=' + b) });

(Sorry for adding more options to the discussion — quick rebuttals as to
why the above wouldn’t work welcome.)

-- 
Cameron McCormack ≝ http://mcc.id.au/
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to