Nov 17 meeting notes

David Bruant bruant.d at gmail.com
Fri Nov 18 07:15:50 PST 2011


Le 18/11/2011 01:40, Waldemar Horwat a écrit :
> Array.from discussion:  What happens if you subclass Array?
> Subarray = Array <| function() {...}
> Subarray.from(arraylike)
Subarray having a 'from' method sounds like a good idea, but it
inheriting it from Array sounds counter-intuitive, because Array is
indeed more of a placeholder than anything else. Very much like
Object.getOwnPropertyDescriptor.
I raised the concern earlier and I still think that we should separate
the 2 different concerns <| is currently addressing.
1) Object.getPrototypeOf(Subarray) === Array (hence the inheritance of
'from')
2) Object.getPrototypeOf(Subarray.prototype) === Array.prototype
(which is convenient for instanciation)

If we had an operator dedicated to 2, there wouldn't be any
Subarray.from method.
Just for this email, i'll use <|| for 1 and <<| for 2 (for explanatory
purposes, not as syntax proposition)

> MarkM: Now these functions are this-sensitive and will fail if
> extracted and called indirectly.
> DaveH: Replace 'new this()' with 'new (this || Array)()' above.
> MarkM: Of all of the static methods in ES5, not one of them is
> this-sensitive.  The simple extraction of a static method fails,
> thereby making static methods not be first-class.  If Math.sin did
> this, you couldn't map it over an array.  With this, you can't map
> Array.of over an array.
What about Function.prototype.of? Or rather:
-----
ArrayLikeCstrProto = Function.prototype <|| {of:function(){}};
// "of" is the this-sensitive one
// In essence: Array.of = ArrayLikeCstrProto.of.bind(Array);

Subarray = ArrayLikeCstrProto <|| Array <<| function(){}
-----
Subarray.of is inherited from ArrayLikeCstrProto.
Instance prototype chain:
(new Subarray) --> Subarray.prototype --> Array.prototype --> ...


> Direct Proxies slide show.
>
> (...)
>
> Attach:
> (...) A number of us want
> value observers and feel that proxies are less useful without them.
What is wrong with a separate API like
http://wiki.ecmascript.org/doku.php?id=strawman:observe ?

> Consensus: Direct proxies (other than startTrapping/attach) accepted
> for ES.next to replace older proxies proposals and strawmen.
Great!

David


More information about the es-discuss mailing list