Topic: APLX Help : Help on APL language : System Methods : ⎕CLASSREF Reference to object's class
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕CLASSREF Reference to object's class


Implemented for Internal and External classes. Not implemented for System classes.

Syntax:

    classref ← objref.⎕CLASSREF
    classref ← classref.⎕CLASSREF
    classref ← ⎕CLASSREF     (Within user-defined method, same as ⎕THIS.⎕CLASSREF)

The niladic system method ⎕CLASSREF returns a reference to the class of an object, as a scalar. It can also be used with a class reference rather than an object reference, in which case it returns the class reference unchanged.

It can be used with both internal and external classes (but not system classes). However, it is an optional feature for external classes; it is implemented for .Net, Java and Ruby, but is not implemented for R.

      DT←'.net' ⎕NEW 'System.DateTime' 2007 5 30
      DT                 ⍝ DT references an object of the .Net DateTime class
[.net:DateTime]
      CL←DT.⎕CLASSREF
      CL                 ⍝ CL is a reference to the DateTime class itself
{.net:DateTime}

A class reference obtained in this way can be used to create a new object of the same class, by using the class reference as the right argument of ⎕NEW (rather than a character vector). In this case, it is not necessary to specify the architecture as the left argument of ⎕NEW:

      DT2←⎕NEW CL 2007 9 20 12 13 44  ⍝ CL can be used to make a new object
      DT2                             ⍝ of the same class as DT
[.net:DateTime]
      DT2.⎕DS
20/09/2007 12:13:44
  

Topic: APLX Help : Help on APL language : System Methods : ⎕CLASSREF Reference to object's class
[ Previous | Next | Contents | Index | APL Home ]