Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕INSTANCES Instances of a Class or Descendants
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕INSTANCES Instances of a Class or Descendants


The monadic or dyadic system function ⎕INSTANCES returns a vector of references to all the instances of a given internal class. The right argument is either a class reference, or a character vector containing the name of an internal class.

If the left argument is omitted, or is 0, the list will include instances of the specified class and of any descendants of the class. If the left argument is 1, the list will be restricted to instances of the specified class itself only.

In this example, classes Rectangle and Triangle both inherit from class Polygon:

      )CLASSES
Polygon Rectangle       Triangle
      T1←⎕NEW 'Triangle'  ⋄ T1.⎕DF 'Triangle1'

      T2←⎕NEW 'Triangle'  ⋄ T2.⎕DF 'Triangle2'

      P1←⎕NEW 'Polygon'  ⋄ P1.⎕DF 'Polygon1'

      R1←⎕NEW 'Rectangle'  ⋄ R1.⎕DF 'Rectangle1'

      ⎕INSTANCES 'Polygon'    ⍝ Form using class name as right arg
Triangle1 Triangle2 Polygon1 Rectangle1
      0 ⎕INSTANCES Polygon    ⍝ Form using class reference as right arg
Triangle1 Triangle2 Polygon1 Rectangle1
      1 ⎕INSTANCES Polygon
Polygon1
  

⎕INSTANCES cannot be used to find instances of external classes.


Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕INSTANCES Instances of a Class or Descendants
[ Previous | Next | Contents | Index | APL Home ]