[Idea:] Introduce Super(arg) usage for Fat arrow functions Topic is solved

Discuss the future of the AutoHotkey language
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

[Idea:] Introduce Super(arg) usage for Fat arrow functions

Post by V2User » 16 Jul 2023, 11:20

Wish => could support Super(arg).
Code:

Code: Select all

f(ths)=>ths.fc() ; It seems convenient to support f(ths)=>Super(ths).fc() also.
CCC.Prototype.DefineProp('ff',{call:f})
CCC().ff()
Class CC{
	fc(){
		OutputDebug("Super")
	}
}
Class CCC extends CC{
	fc(){
		OutputDebug("this")
	}
}
Currently, => can support 'this' through ths. Maybe it can also support 'Super' usage through Super(ths). Although this time keyword Super acts more similar to a function accepting an extra arg.

lexikos
Posts: 9635
Joined: 30 Sep 2013, 04:07
Contact:

Re: [Idea:] Introduce Super(arg) usage for Fat arrow functions  Topic is solved

Post by lexikos » 16 Jul 2023, 21:10

What are you expecting it to do?

The whole point of super is that it is relative to the class which contains the method definition, not the runtime class of this. In your example there is no class associated with the function.

this is just a parameter and local variable, implicit for methods. If the function is called as a method, it will be passed this parameter. If a closure is defined inside a method, it can capture the method's this parameter. In that case, maybe super.method() could be made to work like (BaseClass.method)(this), but obviously you can already do the latter. And this doesn't apply to f in your example; that is just an ordinary global function.

Post Reply

Return to “AutoHotkey Development”