tc39 / proposal-slice-notation

http://tc39.es/proposal-slice-notation/
MIT License
526 stars 19 forks source link

Works with ES6 proxy #34

Closed yorkie closed 4 years ago

yorkie commented 4 years ago

The Proxy's get trap handler would deal with the followings:

Does this mean that the slice syntax will be merged into 2nd, the item accessor? If yes, we have to extend the handler arguments, because it's 3 at most as:

{
  get: function(target, start, stop, step) {...}
}

(Actually Proxy/ES doesn't have distinct declaration about the above 2 accessors, it makes developers confused a bit, and hard to extend for special item accessor like slice notation).

j-f1 commented 4 years ago

If a well-known Symbol method ends up being used, I’d guess it would call the get trap to get the value of the method, then call it with the slice info.

yorkie commented 4 years ago

@j-f1 do you have any example here? IMO the issue is how to resolve the arguments conflict of get trap on the proxy object o[x:y:z].

ljharb commented 4 years ago

@yorkie you're assuming that slice notation would be a new kind of complex Get. @j-f1 is saying it could be a Get of a Symbol.slice function, which is then invoked - which would not require any changes in Proxy.

yorkie commented 4 years ago

Thank you @ljharb, it resolves the problem eventually, and the slice notation is not going to get object property, the intention of the Proxy get handler at MDN:

The handler.get() method is a trap for getting a property value.