Proposal: Object.defineProperty shorthand

Brendan Eich brendan at mozilla.com
Wed Jun 1 00:00:06 PDT 2011


On May 31, 2011, at 2:25 PM, Allen Wirfs-Brock wrote:

> This is as plausible as using ! for non-configurable as I had proposed.  It really comes down to alignment with other uses of #.  It is pretty easy to make a logical association between this mapping of symbols to meanings.   However, it would be pretty cryptic  if we every needed to add a fourth or fifth attribute systems.

I hope we don't add attributes without strong reason. Any more in sight?


> but if 
>   #bar() {}
> or
>  #baz()->{}
> is valid in general expressions, then what is the meaning of:
> var foo = {
>    #bar() {},
>    #baz()->{}
> }
> 
> is it:
> 
> var foo = {
>    #bar: #bar() {},
>    #baz: #baz()->{}
> }
> or
> var foo = {
>    bar: #bar() {},
>    baz: #baz()->{}
> }

Per Mark's const functions and the const class adjective, I'd see and raise the former:

var foo = {
   #!~bar: #bar() {},
   #!~baz: #baz()->{}
}

The idea is to provide maximum integrity. Anything else, you'll have to spell out with punctuation, property name, colon, and the value.

IIRC, methods already imply ~ in your proposal, so that's expanded above in my bid ;-).

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110601/b24faf6f/attachment.html>


More information about the es-discuss mailing list