> Sure, Object.create(proto).extend({k1:v1, ... kN:vN}).
> 
> If you want to make that one method instead of two, a new Object.createSimple 
> or better name would be needed.

Such a method would be very useful independently of this use case!

I would also love to have turn Object.defineProperties into a similar method. 
Naming-wise, one could introduce a new system, for example:

- Object.createSimple(proto, props?) versus Object.createDesc(proto, descs?)
- Object.prototype.extendSimple(props) versus Object.prototype.extendDesc(descs)
   => use something more complex than "extend" to avoid name clashes.

Advantage: Mix normal property definitions with property descriptors:

    var obj = {
        count: 3,
    }. extendDesc({ MAX_COUNT: { value: 10, writable: false, configurable: 
false } });


== Big picture ==

1. The two most prevalent use cases are handled by:
    - property definitions in object literals (thanks to Allen’s operators, 
those can be used in many more places now).
    - the proposed "#" prefix for read-only properties.
    => easy to understand new syntax, lightweight (little grawlixing), sticking 
to 80-20.
2. More complex requirements can be handled by using property descriptors.

#2 would become more lightweight by additional syntax, but it seems like that 
has already been discussed and rejected:
    var obj = {
        count: 3,
        MAX_COUNT := { value: 10, writable: false, configurable: false },
    }

Thus: If one uses ":=" (previously: const-ification) then the RHS is a property 
descriptor. This would also be nicely future-proof with regard to possible 
upcoming property descriptor extensions.

-- 
Dr. Axel Rauschmayer

[email protected]
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



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

Reply via email to