Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-31 Thread Jason Orendorff
On Tue, May 28, 2013 at 7:15 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: ES6 could provide a Mapping class, in a standard module, that works like this: https://gist.github.com/jorendorff/5662673 All those methods are generic. Map would be a subclass of Mapping, with its own fast

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-31 Thread Tab Atkins Jr.
On Fri, May 31, 2013 at 8:05 AM, Jason Orendorff jason.orendo...@gmail.com wrote: On Tue, May 28, 2013 at 7:15 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: ES6 could provide a Mapping class, in a standard module, that works like this: https://gist.github.com/jorendorff/5662673 All

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-28 Thread Jason Orendorff
On Fri, May 24, 2013 at 8:28 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Fri, May 24, 2013 at 4:14 PM, Jason Orendorff jason.orendo...@gmail.com wrote: It seems rather heavyweight. You can already get about the same effect just by writing that wrapper yourself. As I've argued and

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-28 Thread Jason Orendorff
On Tue, May 28, 2013 at 1:00 PM, Jason Orendorff jason.orendo...@gmail.comwrote: I still think WebIDL might be the way to go. After all it is WebIDL support that makes your current spec language possible. But I have one more possibly productive suggestion, which I'll try to post today. ES6

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-28 Thread Tab Atkins Jr.
On Tue, May 28, 2013 at 12:21 PM, Jason Orendorff jason.orendo...@gmail.com wrote: On Tue, May 28, 2013 at 1:00 PM, Jason Orendorff jason.orendo...@gmail.com wrote: I still think WebIDL might be the way to go. After all it is WebIDL support that makes your current spec language possible. But I

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-25 Thread Tom Van Cutsem
2013/5/24 Tab Atkins Jr. jackalm...@gmail.com What does the invoke trap do? It looks like it somehow covers the p.foo() case? Can it handle var f = p.foo.bind(p); f(); as well? Just pointing me to docs would be sufficient, if they exist yet. Given that invoke() was only just now

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-25 Thread Tom Van Cutsem
2013/5/24 Tab Atkins Jr. jackalm...@gmail.com The problem is that the Map#set method grabs an *internal property*, bypassing Proxies, etc., so you can't defend against it. Just to clarify, grabbing internal properties doesn't bypass proxies, not as currently specced. That's why

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Tom Van Cutsem
As I mentioned upstream, I don't think extending the Proxy API with hooks for accessing the private state of every possible built-in is going to fly. Here's a constructive counter-proposal: The difficulty of your use case is that you ideally would want to use inheritance to inherit all of Map's

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Jason Orendorff
Map-like objects people will want include: - something that looks like a Map, but backed by something other than [[MapData]], like DOM attributes, a JS object's properties, a hash table that doesn't retain entry order, or a key-value store; - an observable Map; - a Map that generates new

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Tab Atkins Jr.
On Fri, May 24, 2013 at 7:02 AM, Tom Van Cutsem tomvc...@gmail.com wrote: As I mentioned upstream, I don't think extending the Proxy API with hooks for accessing the private state of every possible built-in is going to fly. Here's a constructive counter-proposal: The difficulty of your use

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Tab Atkins Jr.
On Fri, May 24, 2013 at 9:27 AM, Jason Orendorff jason.orendo...@gmail.com wrote: Map-like objects people will want include: - something that looks like a Map, but backed by something other than [[MapData]], like DOM attributes, a JS object's properties, a hash table that doesn't retain

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Andreas Rossberg
On 24 May 2013 18:55, Tab Atkins Jr. jackalm...@gmail.com wrote: I simply don't understand why Javascript's Map apparently makes this impossible, forcing all Maps to be any-any, and offering only hacks (admittedly clever ones) that partially work if you want a restricted type. I haven't

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Jason Orendorff
On Fri, May 24, 2013 at 12:02 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Fri, May 24, 2013 at 9:27 AM, Jason Orendorff jason.orendo...@gmail.com wrote: Counterproposal: address this in WebIDL. Add a magic [Maplike] tag that means something like: [...] [...] It's not the *best*

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Tab Atkins Jr.
On Fri, May 24, 2013 at 11:53 AM, Jason Orendorff jason.orendo...@gmail.com wrote: On Fri, May 24, 2013 at 12:02 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Fri, May 24, 2013 at 9:27 AM, Jason Orendorff jason.orendo...@gmail.com wrote: Counterproposal: address this in WebIDL. Add a

RE: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Ron Buckton
. Sent: Friday, May 24, 2013 5:08 PM To: Jason Orendorff Cc: EcmaScript Subject: Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?) On Fri, May 24, 2013 at 11:53 AM, Jason Orendorff jason.orendo...@gmail.com wrote: On Fri, May 24, 2013 at 12:02 PM, Tab Atkins

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Tab Atkins Jr.
On Fri, May 24, 2013 at 2:35 PM, Ron Buckton rbuck...@chronicles.org wrote: Another way to look at this is that there is no way to prevent a caller from using methods from the superclass on a subclass. In other OO languages, its much harder (or nearly impossible depending on the language) to

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Sam Tobin-Hochstadt
On Fri, May 24, 2013 at 5:52 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Fri, May 24, 2013 at 2:35 PM, Ron Buckton rbuck...@chronicles.org wrote: Another way to look at this is that there is no way to prevent a caller from using methods from the superclass on a subclass. In other OO

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Tab Atkins Jr.
On Fri, May 24, 2013 at 4:14 PM, Jason Orendorff jason.orendo...@gmail.com wrote: On Fri, May 24, 2013 at 4:52 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: The problem is that the Map#set method grabs an *internal property*, bypassing Proxies, etc., so you can't defend against it. If I

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-23 Thread Tab Atkins Jr.
On Tue, May 21, 2013 at 4:07 AM, David Bruant bruan...@gmail.com wrote: David Bruant wrote: Le 21/05/2013 04:06, Tab Atkins Jr. a écrit : (One way to do this today is to subclass Map and provide my own get/set/etc. functions, but I need to override a potentially-open set (anything that

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-22 Thread Tom Van Cutsem
2013/5/21 David Bruant bruan...@gmail.com Would it make sense to add specific traps for specific objects (Date would have some specific traps, so would objects with [[MapData]], so would objects with [[SetData]], etc.)? Very much like functions currently have some traps that only apply to

Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-21 Thread David Bruant
Hi, David Bruant wrote: Le 21/05/2013 04:06, Tab Atkins Jr. a écrit : (One way to do this today is to subclass Map and provide my own get/set/etc. functions, but I need to override a potentially-open set (anything that doesn't directly lean on my overridden functions), and it doesn't

Re: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-21 Thread Tab Atkins Jr.
On Tue, May 21, 2013 at 4:07 AM, David Bruant bruan...@gmail.com wrote: David Bruant wrote: Le 21/05/2013 04:06, Tab Atkins Jr. a écrit : (One way to do this today is to subclass Map and provide my own get/set/etc. functions, but I need to override a potentially-open set (anything that