This might be a dumb question: TCP = "this-context preservation"?
(Sorry, my brain has that acronym hard-linked to "Transport Control
Protocol" and I keep getting confused.)

On Wed, Mar 7, 2012 at 13:01, Gavin Barraclough <barraclo...@apple.com> wrote:
> But (modulo separate "do" TCP proposal of yesterday) shorter function syntax
> is just syntax. No TCP, no lexical |this| in particular.

Yes, "functionless function" proposal is just syntax, not a change in
semantics.  IIUC, reducing the syntax weight of callable-things
(whether functions or freaky-deaky lambda things) is a goal in itself.

Assuming that we get "() do {}" as the freaky-deeky syntax, would that
do the TCP stuff?  If so, why not drop block-lambdas, and do the TCP
stuff by saying that single-return-expression functions are the ones
that do TCP and other freaky stuff?  Then you can treat "do {...}" as
an expression, somewhat like a block lambda that takes no arguments
and is invoked when evaluated.

Then you really have three somewhat modest proposals:

1. optional "function".
2. braceless functions that auto-return the completion value of the
expression and exhibit TCP freakdeekness.
3. do-expressions blocks that evaluate to their completion value.

These three seem to combine to let you do all the good things that
block lambdas offer, and are pretty elegant and easy enough to explain
to new users, IMHO.  The "do" token sort of looks like it means "Do
this right here, not in a separate context".

It seems like #2 would require the most ironing out.  For example: `x
= (y) +1` is ambiguous, as is `x = (y)(z)` and many many others.  If
we use `do {...}` (or something) as an unambiguous "this is an
expression", then that could be a nice escape hatch.  Ie, `x = (y) do
{ 1 }` would be akin to `x = tcp_freaky_deeky(function (y) { return 1
})`.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to