Re: Proposal: Proxy iteration (`let ... of ...`) trap handler

2016-09-25 Thread Alexander Jones
Yes, please don't special case for-of handling, it's nicely expressed in terms of other concepts. On Sunday, 25 September 2016, saam barati wrote: > It seems like Jordan's suggestion is what you want then. > > - Saam > > On Sep 24, 2016, at 9:54 PM, Tycho Grouwstra > wrote: > > Thank you. > > T

Re: Proposal: Proxy iteration (`let ... of ...`) trap handler

2016-09-24 Thread saam barati
It seems like Jordan's suggestion is what you want then. - Saam > On Sep 24, 2016, at 9:54 PM, Tycho Grouwstra wrote: > > Thank you. > > To elaborate a bit, what I'm trying to do is use Proxy so as to enable > FSM-like DSLs, essentially having one Proxy type represent the current > 'state'

Re: Proposal: Proxy iteration (`let ... of ...`) trap handler

2016-09-24 Thread Tycho Grouwstra
Thank you. To elaborate a bit, what I'm trying to do is use Proxy so as to enable FSM-like DSLs, essentially having one Proxy type represent the current 'state' dictating what DSL you're in, one property access choosing to either yield a new proxied object, yielding an unwrapped version, or one wr

Re: Proposal: Proxy iteration (`let ... of ...`) trap handler

2016-09-24 Thread saam barati
The purpose of the iterator protocol is to be flexible and to work well with custom defined iterators. for...of is more or less sugar around the iterator protocol. Not sure why you even need a Proxy to easily customize for...of behavior for arbitrary objects. More documentation on the protocol

Re: Proposal: Proxy iteration (`let ... of ...`) trap handler

2016-09-24 Thread Jordan Harband
Does a trap for `[[Get]]` on `Symbol.iterator` not provide you the ability to intercept iteration by returning a custom function? On Sat, Sep 24, 2016 at 8:34 PM, Tycho Grouwstra wrote: > I'd like to propose adding support for an iteration trap handler for > Proxy, fleshing out the list of [curr

Proposal: Proxy iteration (`let ... of ...`) trap handler

2016-09-24 Thread Tycho Grouwstra
I'd like to propose adding support for an iteration trap handler for Proxy, fleshing out the list of [currently supported Proxy handlers]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Methods_of_the_handler_object ). I think Proxy is among the most powerful