block-lambda revival

Jorge jorge at jorgechamorro.com
Thu Jun 23 15:14:41 PDT 2011


On 23/06/2011, at 23:01, Marc Harter wrote:

> Peter Michaux encouraged me to write my thoughts on es-discuss so here I am.
> 
> Out of the various new function syntaxes proposed ( ->, #, {||} ) I
> have really taken a liking to the block-lambda revival strawman.  I
> think in general they all address similar wishes (e.g. implicit
> return, this, shorter). I prefer the block-lambda because of some use
> cases:
> 
> let a = [1,2,3,4];
> let b = a.reduce((a,b) -> a + b) // didn't see an example for this one
> assuming this is how it looks
> let b = a.reduce {|a,b| a + b} // less cluttery, fn bound by braces,
> couple characters less to type
> 
> Self executing function expressions
> 
> (-> {
>  // multi-line
> }())
> 
> {||
>  // multi-line -- i'm assuming there wouldn't need to be parens
> around the whole thing because block lambdas are expressions not
> statements (is this the case with arrow?)
> }()
> 
> I like block-lambda because:
> 
>  1. From my understanding braces aren't going away, lets just embrace
> them (use them as part of the syntax)
>  2. Arrow gets too bulky with braces (although worked good for CoffeeScript)
>  3. Seems to be terse yet clear
>  4. Encloses the function
> 
> It may be nice to have side by side comparisons of the different
> proposals doing the same operation.

Here: <http://jorgechamorro.com/blocks.html>

> Anyway, my 2 cents.  Thanks!

{|| ... } for shorter *function* syntax is my favorite too. +1(e9)

Also, if any { block } could be a lambda, perhaps we won't need that (nor any new) syntax for block-lambdas.

Also, I'd prefer to know/see clearly when a function is being call()ed, so I'm not very fond of paren-free calls: foo(bar) is clearly an invocation, unlike foo bar, and readability is more important than saving a few keystrokes.

The C language is still (and -ISTM- will be for a long time) important, so -IMO- every little bit of JS's C-like syntax is a plus: less to learn: an old, popular, widely used, well-known, and familiar syntax.

JS -unlike other languages- is important enough that it does not need to follow these (dubious) trendy fashions to become popular. Nor to survive.

Proper punctuation aids comprehension and we're programming, not writing quick SMSs.
-- 
Jorge.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110624/e0235f81/attachment.html>


More information about the es-discuss mailing list