List all the methods from a base class?

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: List all the methods from a base class?

Re: List all the methods from a base class?

Post by A_AhkUser » 20 May 2017, 09:58

Code: [Select all]GeSHi © Codebox Plus

Class C {

prop := 7
__Init() {
var := "test"
}

} ; Error at line 148. Line Text: __Init Error: Duplicate declaration. The program will exit.


> Doesn't work: duplicate declaration due to the prop instance variable declaration:

documentation wrote:These declarations are evaluated each time a new instance of the class is created with the new keyword. The method name __Init is reserved for this purpose (...)


Code: [Select all] [Expand]GeSHi © Codebox Plus



>It appears that this works - however the documentation asserts that
[__init method] should not be used by the script


Code: [Select all] [Expand]GeSHi © Codebox Plus



> Works since the method name doesn't start with two underlines; it is not a meta-function.

Re: List all the methods from a base class?

Post by Helgef » 19 May 2017, 22:37

Btw, init!=__Init.

Re: List all the methods from a base class?

Post by A_AhkUser » 19 May 2017, 18:41

Naturally since you loop throught .base - compare:

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: List all the methods from a base class?

Post by jeeswg » 19 May 2017, 18:09

This is interesting, it's one of the few times I've seen __Class or __Init anywhere. Btw so if you test this on a normal AHK object, it shows nothing?

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: List all the methods from a base class?

Post by Helgef » 19 May 2017, 17:50

That is nicer :xmas:

Re: List all the methods from a base class?

Post by lexikos » 19 May 2017, 17:20

this.base refers to the class directly. :facepalm:

Re: List all the methods from a base class?

Post by Helgef » 19 May 2017, 14:06

Indeed, see %var% (double-deref).
Cheers.

Re: List all the methods from a base class?

Post by tic » 19 May 2017, 13:55

I had not tried putting the percentages around a. Very odd syntax, considering both k and v are objects and do not require % to qualify them.
Anyway, thanks!

Re: List all the methods from a base class?

Post by Helgef » 19 May 2017, 13:50

Code: [Select all]GeSHi © Codebox Plus

a:=this.__Class
for k, v in %a%

List all the methods from a base class?

Post by tic » 19 May 2017, 13:33

How can we list all the methods from a baseClass?

The following will work by explicitly using MyClass by name, but how can we use this to get the methods myMethod1 and myMethod2?

Code: [Select all] [Expand]GeSHi © Codebox Plus


Top