## ŒGETCLASS Get reference to named class

The system function ŒGETCLASS returns a reference to a named Internal or External class. It is not implemented for System classes.

The left argument is a character vector which specifies the environment in which the class exists, in the same format as for ŒNEW. It can be omitted, in which case it is assumed that the class is an internal (user-defined) class in the workspace. The right argument is a character vector containing the name of the class. If the class is found, a scalar reference to the class is returned:

          ŒGETCLASS 'Point'
    {Point}
          (ŒGETCLASS 'Point').ŒNL 2
    X
    Y
    Z

In this Java example, we fetch a reference to the class `TimeZone`, which can then be used to call a static method.

          tzclass„'java' ŒGETCLASS 'java.util.TimeZone'
          tzclass.ŒCLASSNAME
    java:java.util.TimeZone
          tz„tzclass.getTimeZone 'America/Los_Angeles'

Note: If you are creating many thousands of instances of an external class, it may be much more efficient to use ŒGETCLASS to fetch a reference to the class once, and pass that reference to ŒNEW, rather than passing the class name to ŒNEW.

If you )SAVE a workspace containing references to external classes, the references will be set to ŒNULL when the workspace is reloaded.

Topic: APLX Help : Help on APL language : System Functions & Variables : ŒGETCLASS Get reference to named class

[ Previous | Next | Contents | Index ]