On Mar 6, 2012, at 2:37 PM, Brendan Eich wrote:
> You didn't show the expression-bodied variant:
>
> myList.map((x) x + 1)
>
>
> which is even shorter, if it's doable at all (I haven't worked out a good
> grammar yet).
That's actually a pretty good space to aim at, IMO. I conjecture the majority
cases where you really want the concise notation is for an expression body.
Moreover, if you wanted to do some control along with an expression, you could
use do-expressions:
myList.map((x) do { for (...) { ... } f(x) })
Note that combination (expression closures + do-expressions) brings back the
exact same expressiveness of block-lambda. Of course, I consider that to be a
feature, not a bug!
> Longer braced-body cases are where completion-leaks can hide. If you write
> functional/expression-langauge-y JS then you'll be ok. If you start to write
> control statements with early returns you may run into trouble.
I can believe that. Do you think do-expressions would mitigate the risk? I
suspect they might, by virtue of the explicit opt-in via the keyword at the
head.
>> Moreover, it essentially means abandoning ever having TCP lambda.
>
> Why?
Just because there are only so many variations on function syntax we're going
to add to the language.
>> Now, I know that some in the community look at block-lambda with suspicion
>> (although I'm tempted to call BLUB -- don't knock it till you've tried it).
>> As ever, we have kind of a Mexican stand-off between
>>
>> - block lambda (funky pipes, freaks some people out)
>
> We went around the block with {(...)...} vs. {|...|...} and everyone jumped
> back on the pipes bandwagon. The issue I still see as red meat for the BLUB
> beast is either TCP in general, or just too different-from-C syntactic
> aversion.
Yes, it was TCP I was referring to.
>> - TCP-respecting shorter function (possible return-value leak, freaks some
>> people out)
>
> My point remains that TCP-anything should be delimited by new and
> freaky-deaky syntax. Or else it will (ceteris paribus) result in more
> completion leaks or mistargeted returns or whatever.
I hereby propose expression closures + do-expressions as the new, freaky-deaky
syntax. Thoughts?
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss