Page 1 of 1

Generic invocation of typeMethods

Posted: Tue May 25, 2021 1:01 pm
by gtcp
Is there a way to call a static method using a class reference?

I want to grab a bunch of classes, store references, then pick one and invoke a type method on it. In essence this is something like cls : Class; begin cls := ClassA; …then much later… cls@methodName(); Of course this gives a syntax error because methodName is unknown on Class.

You might think sendTypeMsg would solve this but I seem to need to invoke it on an instance of a class, which defeats the purpose here.

Is there any way to do this?

Re: Generic invocation of typeMethods

Posted: Tue May 25, 2021 4:27 pm
by Kevin
Check out the following:

https://jedi.ideas.jadeworld.com/ideas/JAD-I-401 (JEDI idea about improvements which have shipped in JADE 2020)

viewtopic.php?f=11&t=2377 (workaround for how it can be done in JADE 2018)

Re: Generic invocation of typeMethods

Posted: Wed May 26, 2021 6:29 am
by gtcp
Thanks so much, Kevin. Sure, it's a workaround but it works! Here's a minor bit of polish on that, just wrapping up the oid-wrangling into a method on Class cheekily called static:

Code: Select all

static() : Object; begin return (number.String & '.1').asOid(); end;
That tidies the invocation to cls.static().YourClass@yourMethod().