On Apr 24, 2012, at 2:09 PM, Allen Wirfs-Brock wrote:

> On Apr 24, 2012, at 1:40 PM, David Herman wrote:
> 
>> On Apr 24, 2012, at 10:03 AM, Tab Atkins Jr. wrote:
>> 
>>> There doesn't seem to be a need there for thin-arrow (dynamic this) 
>>> functions.
>>> 
>>> (Edit: Oh, I see, leaning on the completion value of thin-arrow
>>> functions here lets you shave a few characters off.  The readability
>>> loss of mixing the two syntaxes doesn't seem worthwhile, though.)
>> 
>> Lets you eliminate "{" and "}" and "return", but requires additional ":" and 
>> "->". Net savings of 3 characters. But more than that, eliminating "return" 
>> lets you write methods in a functional style without needing the explicit 
>> control flow operator.
>> 
> 
> I believe that we could grammatically use ArrowBody as the body of concise 
> methods in object literals and classes.  In that case, Dave's example could 
> be expressed as:
> 
>     box = {
>         _value: 0,
>         unbox() ()-> this._value,

ITYM:

    unbox() this._value,

>         setbox(v)  this._value = v 
>     }
> 
> It could also be used as the body of getter/setters
> 
>     val = {
>         _value: 0,
>         get value() this._value,
>         set value(v)  this._value = v 
>     }

This all seems reasonable to me. I guess I see a couple reasonable alternatives 
here:

A. add thin arrow, add expression bodies to method shorthands

    (-) Might be a bit much
    (+) But all around a goodly set of convenience forms

B. add expression bodies to method shorthands, don't add skinny arrow

    (-) Loses the flexibility of shorthand syntax for assigning to an existing 
object, a Tab pointed out. (Sorry Axel, mustache is not particularly 
Harmonious.)
    (+) Keeps us to just one arrow form

C. eliminate method shorthands, add skinny arrow

    (-) Loses the method shorthand in object literals
    (-) Methods in classes would remain the same, which loses some symmetry 
between object literals and classes
    (+) Eliminates visual confusion between getters/setters and method 
shorthand, but still with a minimal syntax (i.e., "->")

All three of these options look pretty decent to me. I think I'd be pretty 
happy with any of them.

Dave

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to