On May 29, 2012, at 10:43 AM, Axel Rauschmayer wrote:
>> Beware scenario-solving in an all-or-nothing way. There's no absolute good
>> here, and while people may (due to Prototype's Object.extend) want = not :
>> in most cases, that doesn't mean : is unnecessary.
>
> Define properties manually when you really need it? I agree with Zakas et
> al.: it will be nearly impossible to teach. I have a hard time telling the
> two apart, too.
>
>> Another alternative: give up on mustache since it bends object literal
>> syntax past its breaking point.
>
> I see two options:
>
> 1. Only do =. How will method definitions be done?
> 2. Only do :, but with [[Put]].
Another alternative (or variation on 2) is to use a slightly more distinctive
syntax for object extension literals. For example:
obj=.{ //"damp mustache"??
foo: bar //does a [[Put]] because it is inside =.{
};
But then you still loose the ability to define own data properties. There seem
to be reasonable use cases that require them. For example, defining own
properties within a constructor.
It seems that understanding the difference between defining a property and
assigning to a property is a distinction that JS developers need to learn.
Particularly, as object definition patterns migrate away from definition via
assignment to more declarative forms (class definitions, object literals, class
extension literals, etc.)
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss