Dear Lexikos, from my experience in code writing, it will truly lose much convenience if we can not call a method from a custom object directly followed by a dot.
With this support, we could write:
Code: Select all
class Cls1{
aa:='a1'
f(){
OutputDebug(this.aa)
,OutputDebug(this.bb)
}
}
ob:=Cls1()
f(){
{base:ob,bb:'b2'}.f()
,{base:ob,bb:'c3'}.f()
}
f()
Code: Select all
; AHK VSERION: AutoHotkey_2.0-a133-9819cb2d
class Cls1{
aa:='a1'
f(){
OutputDebug(this.aa)
,OutputDebug(this.bb)
}
}
ob:=Cls1()
f(){
_:=0 ; it's usually unnecessary.
,{base:ob,bb:'b2'}.f()
,{base:ob,bb:'c3'}.f()
}
Compared with defining a property directly to an object like ob.bb:='b2', instead, by creating a custom object based on ob which contains the property bb for extending, the original object ob shared by derived objects could avoid being modified. It would greatly improve flexibility and convenience in some situations.
To sum up, I really wish to add support to allow a custom object to call a method in one line as an expression which it always be.