July 25, 2012 - TC39 Meeting Notes

Rick Waldron waldron.rick at gmail.com
Sat Jul 28 19:58:14 PDT 2012

On Sat, Jul 28, 2012 at 9:04 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> snip

I snipped, but I agree with all of your claims. While evangelizing our
intention to try for a .{} that supported [[Put]] and [[DefineOwnProperty]].

Given something like this...

  a: "apple",
  b = "banana"

The number one resistance to the mixed use use of ":" and "=" was that most
developers did not realize there was a semantic difference and actually
expected us to assume the burden of specifying the magic that would make
this work correctly with just ":"

I submit the following survey results to support the above claim,

(The live form with the survey question is here:

Pay specific attention to the comments where object literal syntax is
frequently suggested as preferential.

...more below

> We introduce a new operator that is looks like  :=

I like this.

> This is the "define properties" operator.  Both the LHS and RHS must be
> objects (or ToObject convertible).  Its semantics is to
> [[DefineOwnProperty]] on the LHS obj a property corresponding to each RHS
> own property.  I does this with all reflectable own properties. It includes
> non-enumerable properties and unique named properties but not
> non-reflectable *private* name properties.  It rebinds methods with super
> bindings to the RHS to new methods that are super bound to the LHS.
> The above example would then be written as:
> a := {
>   push(elem) {
>     ...
>   }
> };
> rather than, perhaps incorrectly as:
> a.push = function (elem) {
>     ...
> };
> or, correctly but very inconveniently as:
> Object.defineProperty(a, "push", {writable: true, configurable: true,
> enumberable: true,
>     data:function (elem) {
>         ...
>         }
>     }
> );

Is there a mechanism for customizing "writable: true, configurable: true,
enumberable: true"?

> Note that while the above example uses an object literal as the RHS, it
> could be any object.  So, := is essentially a operator level definition of
> one plausible semantics for a Object.extend function. Using an operator has
> usability advantages and it also makes it easier to optimize the very
> common case where the RHS will be a literal.
> := is used because it is suggestive of both property definition (the use
> of : in object literals) and of assignment (the = operator).  := also has a
> long history of use as an assignment-like operator in programming
> languages. The visual similarity of = and := should push ES programmers to
> think about then as situational alternatives whose semantic differences
> must be carefully considered.  The simple story is that one is used for
> assigning a value to an existing property and the other is used to define
> or over-ride the definition of properties.
> I really think in a language where we have both [[Put]] and
> [[DefineOwnProperty]] semantics that we really need both = and :=

As noted above, there I feel there is sufficient evidence that supports the
existing confusion and I agree that a syntactic distinction would help
reshape understanding as we move forward.


> Allen

> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120728/9016e606/attachment-0001.html>

More information about the es-discuss mailing list