David Herman wrote:
On Mar 6, 2012, at 1:55 PM, Brendan Eich wrote:
The risk here may be small but people have run into it before in CL and other
LISPs and expression languages. It's a bit scary in JS, what with OCAP the
fundamental security model. So I don't think we should treat it lightly and
TC39 has not, so far.
Perhaps. OTOH, the half-measure of only partly shortening JS functions, i.e.:
myList.map((x) { return x + 1 })
vs
myList.map((x) { x + 1 })
or
myList.map({|x| x + 1})
is disappointing.
I'm kind of encouraged by Isaac raising this idea, since we didn't
(AFAICR) didn't consider a restricted production previously, but anyway,
the hard case for what you propose is not the shortest case.
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).
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.
Moreover, it essentially means abandoning ever having TCP lambda.
Why?
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.
- 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.
- shorter functions with return (still verbose, possible return-value leak,
precludes ever having TCP-respecting lambda)
I do not see why you write "precludes".
Otherwise I see a similar non-trilemma:
1. TCP
2. Short different-from-function syntax
3. Shorter similar-to-function syntax.
I believe you can have 1 and 2 but not 1 and 3. I see no reason why you
can't have 2&3, though, so all of 1-3 is conceivable (we discussed 'fn'
as shorthand for 'function' last time and considered block lambdas as
fitting too -- need methods&blocks not just blocks).
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss