Comments on Sept Meeting Notes

Kevin Smith zenparsing at gmail.com
Thu Sep 26 06:11:02 PDT 2013


After thinking this over, I still remain unconvinced that symbols are the
right solution to the problem.  Besides the fact that they introduce (ever
more) complexity to the object model, they simply do not work as a
duck-typing strategy for the real, *multi-realm* world of Javascript.
 Sure, we can make a special case of standard library symbols such that
they maintain identity across realms.  But a solution which only works for
special cases isn't a very good solution, is it?

Here is another proposal which avoids these pitfalls:

1) Identify all meta-layer hooks using a string that is not an identifier.
 The actual string used doesn't matter in this proposal, but for
illustration purposes I'll use an "@"-prefix.

2) Define all meta-layer hooks as functions.  Testing for the hook will
involve [[Get]] followed by [[IsCallable]].

For example, defining an iterable:

    class C { "@iterator"(...args) { /* ... */ } }

 Overriding the string tag:

    class C { "@toStringTag"() { return "[object C]"; } }

- Since the property name is a non-identifer, it is unlikely to collide
with any object members.
- Since the value of the hook must be a function, it is unlikely to collide
with keys in an object-as-map (e.g. a JSON object).
- Since it is just a string, it requires no changes to property semantics,
and it trivially works across realms.

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130926/c34cdac6/attachment-0001.html>


More information about the es-discuss mailing list