I tried assigning to .base, but that didn't work for me
to tell u what was wrong, id have to see the code
maybe because it changed the underlying type too much
no
thought it might work since both Closure and Enumerator were subclasses of Func.
thats kinda irrelevant, it would have worked regardless of the relationships between the objects
there is currently(a122) no convenient built-in ahk way of subclassing from
Enumerators, which means ull have to do the subclassing urself manually at runtime every time such an object is required(unless u believe all Funcs, BoundFuncs, Closures and possibly other custom objects share Enumerator traits, in which case knock urself out and subclass once at the very start of the script):
- obtain a reference to the built-in Enumerator prototype somehow and keep it around somewhere
- insert said prototype wherever u see fit in ur object's prototype chain
eg,
an instance of Closure is a Closure -> is a Func -> is an Object -> is an Any
an Enumerator prototype is a Func -> is an Object -> is an Any
u can replace the closure's Func prototype with the Enumerator prototype. the new chain then looks like this:
an instance of Closure is a Closure -> is an Enumerator -> is a Func -> is an Object -> is an Any
Code: Select all
global enumeratorPrototype := [].__Enum().Base
...
enmr[] {
get {
t := this
c := this.length + 1
closure := (byref k, byref v:='`vna') => --c>0 ? ((v=='`vna' ? k:=t[c] : (k:=c, v:=t[c])), 1) : (k:=v:='', 0)
closure.Base.Base := enumeratorPrototype
return closure
}
}