On Apr 4, 2011, at 9:51 AM, P T Withington wrote:

> On 2011-04-04, at 12:40, Sam Tobin-Hochstadt wrote:
> 
>>> Renaming:
>>> - I find this syntax slightly unintuitive: import Geometry.{draw: drawShape}
>>> At first glance this would mean for me: rename drawShape to draw. "draw" 
>>> feels to me like the result of the import.
>> 
>> This is based on the destructuring syntax, where this:
>> 
>> let {draw: drawShape} = ... some expression ...;
>> 
>> also binds the identifier |drawShape|.
> 
> FWIW, I read these destructuring patterns backwards too.  Must be a 
> left/right brain thing.  Something I will have to learn the hard way to make 
> it stick.

This does happen, but there's no way to "fix" it for you mano sinestro types 
;-). The property identifier must be a compile-time constant and on the left of 
:, so the variable name into which to destructure is on the right of :.

Fortunately there's a short-hand:

  let {draw, move} = GraphixAPIObject;

where the property id also names the variable to bind.

It has been proposed that this shorthand be supported for structuring as well 
as destructuring:

  saveObject({draw, move});

would pass a new Object created as if by the initialiser ({draw: draw, move: 
move}). The property id is treated as an identifier expression and evaluated to 
get the property value.

We have some support for this on TC39 but it keeps dropping off the radar. 
Comments welcome.

/be

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to