Generic invocation of typeMethods

The use of specific JADE features and proposals for new feature suggestions
gtcp
Posts: 6
Joined: Tue May 18, 2021 6:28 am

Generic invocation of typeMethods

Postby gtcp » Tue May 25, 2021 1:01 pm

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?

Kevin
Posts: 29
Joined: Wed Oct 14, 2009 9:03 am
Location: Christchurch

Re: Generic invocation of typeMethods

Postby Kevin » Tue May 25, 2021 4:27 pm

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)

gtcp
Posts: 6
Joined: Tue May 18, 2021 6:28 am

Re: Generic invocation of typeMethods

Postby gtcp » Wed May 26, 2021 6:29 am

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().


Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests

cron