Re: proxies: stratifying toString, valueOf

2011-10-18 Thread Erik Arvidsson
On Mon, Oct 17, 2011 at 13:42, Brendan Eich bren...@mozilla.com wrote: Maybe we can hold the line at private-named iterate and defaultValue unstratified traps. I'm looking for two things: 1. Feedback from implementors on not trapping non-proxy objects based on private names being mapped.

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread David Bruant
Le 17/10/2011 03:29, Andreas Gal a écrit : (...) Fixing this just for proxies by stratifying toString, valueOf seems undesirable. We would grant extra powers to proxies, and suddenly this following two ways to invoke toString would produce different results (potentially):

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread David Bruant
Le 17/10/2011 07:19, David Herman a écrit : I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps. They are base-level property accesses. Well, certainly that's the way the language currently

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Dean Landolt
On Mon, Oct 17, 2011 at 1:19 AM, David Herman dher...@mozilla.com wrote: I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps. They are base-level property accesses. Well, certainly that's

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Brendan Eich
On Oct 17, 2011, at 12:43 AM, David Bruant wrote: Le 17/10/2011 07:19, David Herman a écrit : I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps. They are base-level property accesses.

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread David Bruant
Le 17/10/2011 17:31, Brendan Eich a écrit : On Oct 17, 2011, at 12:43 AM, David Bruant wrote: Le 17/10/2011 07:19, David Herman a écrit : I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps.

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Brendan Eich
On Oct 17, 2011, at 8:45 AM, David Bruant wrote: Le 17/10/2011 17:31, Brendan Eich a écrit : On Oct 17, 2011, at 12:43 AM, David Bruant wrote: Le 17/10/2011 07:19, David Herman a écrit : I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language)

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Brendan Eich
On Oct 16, 2011, at 10:19 PM, David Herman wrote: I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps. They are base-level property accesses. Well, certainly that's the way the language

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Allen Wirfs-Brock
On Oct 17, 2011, at 9:20 AM, Brendan Eich wrote: Back to a Proxy defaultValue trap. It should be derived as you say. It imposes no overhead on base-level objects. It seems unproblematic, but I can't for the life of me recall why it was left out. Mark or Tom would know. The only polymorphic

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Tom Van Cutsem
2011/10/17 Brendan Eich bren...@mozilla.com Back to a Proxy defaultValue trap. It should be derived as you say. It imposes no overhead on base-level objects. It seems unproblematic, but I can't for the life of me recall why it was left out. Mark or Tom would know. My guess is we left out

Re: proxies: stratifying toString, valueOf

2011-10-17 Thread Brendan Eich
Maybe we can hold the line at private-named iterate and defaultValue unstratified traps. I'm looking for two things: 1. Feedback from implementors on not trapping non-proxy objects based on private names being mapped. 2. A principled approach to holding the line. /be On Oct 17, 2011, at

proxies: stratifying toString, valueOf

2011-10-16 Thread David Herman
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,

Re: proxies: stratifying toString, valueOf

2011-10-16 Thread David Herman
Ugh, that formatted poorly, at least in my mail client. Here's the example again: js var obj = Proxy.create(myEmptyHandler, proto); js String(obj) trying: toString trying: valueOf TypeError: can't convert obj to string js obj + trying: valueOf trying: toString

Re: proxies: stratifying toString, valueOf

2011-10-16 Thread Andreas Gal
I don't think this makes sense. This has nothing to do with proxies: js var o = Object.create(null) js o + typein:5: TypeError: can't convert o to primitive type If there is no toString property, toString() on the object will fail. This is not a new problem, even before ES5 this could break:

Re: proxies: stratifying toString, valueOf

2011-10-16 Thread Brendan Eich
On Oct 16, 2011, at 6:29 PM, Andreas Gal wrote: I don't think this makes sense. This has nothing to do with proxies: I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps. They are base-level

Re: proxies: stratifying toString, valueOf

2011-10-16 Thread David Herman
If you want to stratify toString/valueOf in general and for all objects, I would very much support that. I'm not sure I understand what you mean. Do you mean something like: js var obj = Object.create(null, {}); js String(obj) TypeError: can't convert obj to string js

Re: proxies: stratifying toString, valueOf

2011-10-16 Thread David Herman
I agree with Andreas. The implicitly-called base level methods are not meta-methods or (spec language) internal methods. They do not need their own traps. They are base-level property accesses. Well, certainly that's the way the language currently works. But the way it currently works is

Re: proxies: stratifying toString, valueOf

2011-10-16 Thread Axel Rauschmayer
One possibility might be to create some private names, à la |iterate|, which you could use in place to 'toString' and 'valueOf': js import { toString, valueOf } from @meta; js var obj = Object.create(null, {}); js String(obj) TypeError: cannot convert obj to string js