Apologies for something (Postbox?) stripping horizontal spaces out of
that ASCII-art table. Retrying.
/be
Per-real typeof customization API, for two use-cases:
* Value objects (http://www.slideshare.net/BrendanEich/value-objects)
* Opt-in typeof null fixing and unfixing.
Two Map instances, internal to the specification:
ExemplarToTypeofMap: object -> string
TypeofToExemplarMap: string -> object
New Function.setTypeOf static, a peer of Function.defineOperator:
Function.setTypeOf(V, U)
1. Let S = ToString(U)
2. Let T = V
3. If T is null then
3a. If S is not "null" and S is not "object", throw
4. Else
4a. If T is not a value object constructor, throw
4b. T = T.prototype
4c. If TypeofToExemplarMap.has(S), throw
5. Call TypeofToExemplarMap.set(S, T)
6. Call ExemplarToTypeofMap.set(T, S)
From the draft ES6 spec:
11.4.3 The typeof Operator
from Table 31:
+-----------------------+------------------------------------------------+
| ... : ... |
+-----------------------+------------------------------------------------+
| Null | ExemplarToTypeofMap.has(val) |
| | ? ExemplarToTypeofMap.get(val) |
| | : "object" |
+-----------------------+------------------------------------------------+
| ... : ... |
+-----------------------+------------------------------------------------+
| Object (value object) | ExemplarToTypeofMap.has(val) |
| | ? ExemplarToTypeofMap.get(val.[[Prototype]]) |
| | : "object" |
+-----------------------+------------------------------------------------+
Notes:
* "is (not) a value object constructor" and "(is a) value object" TBD
* Value objects are non-extensible so their [[Prototype]] can't change
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss