If you want to create a clean-slate proxy object -- for example, a dictionary -- then you can't predefine toString or valueOf. But this means your object will always fail at the semantic operations [[ToString]] and [[ToPrimitive]]. For example:
> var obj = Proxy.create(myEmptyHandler, proto); > String(obj) TypeError: can't convert obj to string > obj + "" TypeError: can't convert obj to primitive type If you actually instrument the proxy to watch which operations it's trying, you'll see: > var obj = Proxy.create(myEmptyHandler, proto); > String(obj) trying: toString trying: valueOf TypeError: can't convert obj to string > obj + "" trying: valueOf trying: toString TypeError: can't convert obj to primitive type Should we not offer derived traps for toString and valueOf (which, if not defined, default to looking up the "toString" and "valueOf" properties, respectively, on the receiver), to allow for stratified implementation of this reflective behavior, i.e., without polluting the object's properties? Dave PS SpiderMonkey also has the unstratified Object.prototype.toSource, which is used for the non-standard uneval function, for printing out values at the console. This is kind of unfortunate since it suggests a need for another proxy trap, but this time it's not for a standard functionality. _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss