It works fine. However, this really returns a Closure that can function as an enumerator, but it's not itself of the Enumerator type. I'd actually like to add some utility properties/methods that apply to all Enumerators via DefineProp/DefineMethod on the Enumerator prototype -- which I already know how to do.
Code: Select all
enmr ;reverse enumerator of (key,val) or (val) based on arity => (t:=this, c:=this.length + 1, (byref k, byref v:='`vna') => --c>0 ? ((v=='`vna' ? k:=t[c] : (k:=c, v:=t[c])), 1) : (k:=v:='', 0))
Before I can do that though, I need to adjust the code in all my custom enumerators in various places (like the one above), to actually be of the built-in Enumerator type. Is there a simple way to do that? (I tried assigning to .base, but that didn't work for me, maybe because it changed the underlying type too much. I originally thought it might work since both Closure and Enumerator were subclasses of Func.)