Code: Select all
class buffer2 extends buffer {
p1=>NumGet(this,'int64')+this.p2
}
c:={p2:25,base:Buffer2(8)}.p1
Code: Select all
class buffer2 extends buffer {
p1=>NumGet(this,'int64')+this.p2
}
c:={p2:25,base:Buffer2(8)}.p1
You can't re-base {...} with a higher abstraction since it breaks the limitation specified above. But the limitation only applies to the curly brace syntax.If assigning the new base would change the native type of the object, an exception is thrown. An object's native type is decided by the nearest prototype object belonging to a built-in class, such as Object.Prototype or Array.Prototype. For example, an instance of Array must always derive from Array.Prototype, either directly or indirectly.
Code: Select all
class buffer2 extends buffer {
p1 {
get => ( NumGet(this,'int64')+this.p2 )
}
}
myBuff2 := buffer2(8)
myBuff2.base := buffer2(8)
myBuff2.p2 := 25
msgbox(myBuff2.p1)
; can also do this
myBuff2.hello := "world"
msgbox(myBuff2.hello)
; or
anotherBuff2 := buffer2(8)
anotherBuff2.base := myBuff2
; i'm now a function, the best function
anotherBuff2.call := (*) => msgbox("it's me, the function")
anotherBuff2()
; but wait, there's more
msgbox(anotherBuff2.base == myBuff2)
msgbox((anotherBuff2 is Buffer2) " -- " (anotherBuff2 is Buffer))
This static method is typically inherited from the Object, Array or Map class. It performs the following functions:
Allocate memory and initialize the binary structure of the object, which depends on the object's native type (e.g. whether it is an Array or Map, or just an Object).
Thanks for your answer. I have decided to cancel this usage in this situation now. Instead, I have defined properties directly on the buffer obj as an alternative. It can be seen in Bfr.ahk in my recent posts:
This usage will get explained furtherly, in my subsequent script later.can you explain more about the example and the wish?