David Bruant (2013-07-30T02:04:52.000Z)
domenic at domenicdenicola.com (2013-08-04T22:41:21.122Z)
Le 30/07/2013 03:09, Allen Wirfs-Brock a écrit : > Nope. We would have had the same problems if we had kept [[Class]]. In ES<=5.1 [[Class]] is used to conflate situational specific testing for a number of independent characteristics of objects. Some of those characteristics can not be transparently prloxied (for example this object reference directly refers a special object representation with some specific implementation dependent representation of some private state 0) By "this object reference", are you talking about the "this" keyword? Even then, I wouldn't be sure to understand. Which part of ES5.1 are you referring to? I believe a code snippet to explain would make things easier to understand. > There really isn't much. But getting rid of [[Class]] enables us to separate the previously conflated characteristics. When you test for "if O is an exotic array object", what characteristic are you testing for, then? This still feels like branding to me. > One of the goals for ES6 proxies was to enable self-hosting of built-ins. In theory, there is no reason that a proxy couldn't be use buy an implementation to implement its "exotic array objects". However, because the spec. explicitly distinguishes "exotic array objects" from other built-in exotic object and from general proxies, such a host implementation would still have to have a way to identify the proxy-implemented exotic arrays as such and for test for them in every context where the spec. says an "exotic array object" is required. That branding test would be that implementations way of implementing "is O is an exotic Array object". Self-hosted code is privileged and may have some power not described by the ES spec (and as far as I know, that's actually the case both for SpiderMonkey and V8 self-hosted code). So self-hosted code can distinguish an actual array from a proxy, that's not an issue. Non-privileged code being able to distinguish an array and a proxy for an array is more worrisome. > memory safety hazard. Every place that checks for "is O an exotic X object" would have to have a subsequent "is O a Proxy whose target is an exotic X" and take different code paths. If you screw it up, you may have memory safety issues. That's an implementation hazard; not sure what your point is here. Note that the design of proxies (can only be new objects, are limited to an immutable {target, handler} data structure, stratified API, etc.) go a long way in preventing memory safety issues. It sounds reasonable to think that implementors will do the necessary rest of work to prevent these issues in already implemented algorithms. Actually, if the stratification is respected and there is no free bypass, there is no reason to have memory safety issues. > The key things are hard dependencies between native code built-in methods that expect specific fixed object layouts and the actual instances of those objects. I don't think you're answering my point. All tests that methods can pass are pre-conditions. If a proxy can pass the test, it can fake it and then behave mistakenly. If a proxy can't pass the test, then user-land code can distinguish an object from its target. Something has to be given up. And giving up on indistinguishability would defeat the purpose of proxies (and the expectation as feedback on Tom's library suggests). > This has nothing to do with Proxies. > > Consider: oh ok. Sorry about that, I had completely misinterpreted your point here. > no, not with portable ES code. The logic is within Array.isArray, not within the object it is applied to. If some code contains an Array.isArray test, it will behave differently if running against a membrane or normal objects. I don't think that's desirable. For membranes to be transparent, a proxy must be able to behave the *exact* same way its target would. Clearly if the logic of some built-in is within the built-in not within the object it is applied to, this is plain impossible. > What do you mean to "be a Date". I wrote "pretend to be a Date". That's at least to the algorithms testing, no matter how they do it. > The ES6 spec. defines Dateness very specifically. It is an ordinary object (ie, not a Proxy) that has a [[DateValue]] internal data property that can be recognized as such by an implementation. The only way the ES6 spec. provides for creating such an object is via the Date[[@@create]] method defined in 15.9.3.5 of the current draft. This method is inherited by subclass constructors so instances of subclasses of the Date constructor, by default, also will pass the Dateness test. Same problem than above about membrane transparency. Aside, but related: instead of passing a target (an already built object), it might be an interesting idea to have a Proxy constructor that takes an @@create so that the target passes the @@create-related tests.