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: Contacts API -- attribute order

2011-08-25 Thread Andreas Gal
On Aug 25, 2011, at 7:56 AM, Mark S. Miller wrote: [+es-discuss] On Thu, Aug 25, 2011 at 2:40 AM, Cameron McCormack c...@mcc.id.au wrote: +cc public-script-coord -cc,+bcc public-device-apis On 25/08/11 7:38 PM, Andreas Gal wrote: We should take this to the WebIDL list then. The order

Re: Proxy.isProxy (Was: using Private name objects for declarative property definition.)

2011-07-13 Thread Andreas Gal
I really don't think IsProxy is a good idea. It can lead to subtle bugs depending on whether an object is a DOM node, or a wrapper around a DOM node (or whether the embedding uses a proxy to implement DOM nodes or not). In Firefox we plan on making some DOM nodes proxies for example, but not

Re: Proxy.isProxy (Was: using Private name objects for declarative property definition.)

2011-07-13 Thread Andreas Gal
, David Bruant wrote: And in general, the main use case for proxies is to emulate host objects. If there is a language construct that helps separating the two cases, we're going against this use case. David Le 13/07/2011 10:26, Andreas Gal a écrit : I really don't think IsProxy is a good

Re: Proxy.isProxy (Was: using Private name objects for declarative property definition.)

2011-07-13 Thread Andreas Gal
There are various ways that implementation details can get exposed. For example, by toString'ing a method property. I don't see why isProxy is any more of an abstraction leak than toString. It is actually less, if we clearly position it as one of the meta-programming functions that are

Re: Minor type confusion in proxies proposal?

2011-07-01 Thread Andreas Gal
In our implementation we are using a generic object. It has some overhead, and a specific internal descriptor object representation might be a bit faster, but such magic objects that don't allow expando properties are usually pretty surprising to programers. Most of the HTML5 DOM allows

Re: Use cases for WeakMap

2011-05-16 Thread Andreas Gal
Even if you want to store weak-map specific meta data per object, nobody would store that directly in the object. Thats needlessly cruel on the cache since 99.9% of objects never end up in a weak map. Instead one would locate that meta data outside the object in a direct mapped dense area

Re: Use cases for WeakMap

2011-05-14 Thread Andreas Gal
Can you describe those common use cases, and how they are impossible with the current specification? Andreas On May 14, 2011, at 3:05 PM, Oliver Hunt wrote: The more I read the WeakMap spec, the more it seems to prevent the common use cases I know of. Could someone give a few examples of

Re: Use cases for WeakMap

2011-05-14 Thread Andreas Gal
. Can you provide a use case where you have an object key as the usual programming idiom? --Oliver On May 14, 2011, at 3:25 PM, Andreas Gal wrote: Can you describe those common use cases, and how they are impossible with the current specification? Andreas On May 14, 2011, at 3:05

Re: [Harmony Proxies] get/set trap receiver argument unnecessary

2011-04-28 Thread Andreas Gal
was raised by Andreas Gal (CC'ed). SpiderMonkey-related bug [2] Actually we are still going back and forth on this. Proto-climbing might be the wrong selector here. Can call a getter or setter seems to be the better category, and that would be only get and set. get and set definitely do need

Re: typeof null

2011-04-19 Thread Andreas Gal
I think there is pretty broad consensus that this will affect the web. To what extent is unclear. I would be willing to take our nightly testers for a test drive for a couple days to see how badly things break if TC39 is leaning towards making such a change. Before we do that maybe you want to

Re: Question about Weak Maps

2011-04-07 Thread Andreas Gal
Why would you want to enumerate the keys in a weak map? Andreas On Apr 7, 2011, at 4:04 PM, Mikeal Rogers wrote: Weak Maps seems to have superseded ephemeron tables. They are non-enumerable, does this also exclude any call that gives you an array of the current keys? If this is the

Re: [Harmony proxies][Terminology] fixed state of a proxy

2011-03-13 Thread Andreas Gal
There is a little twist to this. You can create a proxy that has separate implementations of [[Call]] and [[Construct]], and by fixing it, it converts to a regular functions. However, this regular function is different from any other non-host function: it behaves different w.r.t. to f() and

Re: On ES Harmony proxies extensibility

2011-01-21 Thread Andreas Gal
Hi David, What does exactly not be trapped mean? If you define a property on a proxy object, the defineProperty trap of the handler is the only method with which that operation can succeed. If defineProperty doesn't exist you want us to just ignore the operation? I think this approach has

Re: for-in evaluation order

2010-12-27 Thread Andreas Gal
Note that almost all implementations break for-in enumeration order for dense arrays, for some definition of dense. Example (firefox): a = [] a[2] = 1 a[1] = 1 a[0] = 1 for (i in a) alert(i) will alert 0, 1, 2 (in that order). Now if you do a[x] = 1 you get 0, 1, 2, x However, if we start

Re: Colons and other annotative characters

2010-11-22 Thread Andreas Gal
I think there is too much fear of changing the semantics of for-in. Its semantics is already rather fuzzy. Allowing meta-programmability of for-in (instead of creating a new for-:) syntax doesn't create any additional surprises or hazards for JS programmers. 1. We have already agreed on an