[Wish] Wish to add support for custom objects to allow calling a method directly
Posted: 29 Apr 2021, 09:41
@lexikos
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:
However, without this support, we have to write:
Is there any necessity to add a line like _:=0 or a:={base:ob,bb:'b2'},a.f() in some situations just to avoid an error to make the code run? By the way, in my opinion, due to the brace } is followed by a dot, It would never conflict with any previous syntax.
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.
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.