Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕GETCLASS Get reference to named class
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕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 | APL Home ]