Topic: APLX Help : Help on APL language : System Methods : ⎕MIXIN Mix another class into object
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕MIXIN Mix another class into object


Implemented for Internal classes only (but right argument can be External or System class).

Syntax:

    {arch} objref.⎕MIXIN Class Arg1 Arg2..
    mixin_ref ← {arch} objref.⎕MIXIN Class Arg1 Arg2..
    {arch} ⎕MIXIN Class Arg1 Arg2..  (Within user-defined method, same as ⎕THIS.⎕MIXIN)
    mixin_ref ← {arch} ⎕MIXIN Class Arg1 Arg2..    "

The System Method ⎕MIXIN allow you to mix another class into an object. This has the effect of adding the properties and methods of the mixin to the main object. The mixin can be another internal (APL class), or a system class (such as Window), or an external class (.Net, Java, etc).

⎕MIXIN has a similar syntax to ⎕NEW; the right argument is the class reference (or name, as a text vector), followed by any arguments to the constructor for the class you are mixing-in. The left argument can be omitted if you are mixing-in an APL class, otherwise it defines the architecture for the mix-in. For example:

      ⍝ Mix in an APL class, no arguments to constructor
      inv.⎕mixin Fax     
      
      ⍝ Mix in a Java class, no arguments to constructor
      'java' inv.⎕mixin 'java.util.Date'
      
      ⍝ Mix in a .Net class, with arguments to constructor
      '.net' inv.⎕mixin 'DateTime' 2004 5 6
      
      inv.⎕mixins
[Fax] [java:Date] [.net:DateTime]

The explicit result of ⎕MIXIN is the underlying object reference which has been mixed in to the object, but with display potential switched off. (In other words it is a 'shy' or non-printing result). You can assign this to a variable or property of your APL class, and use this to call the underlying object directly:

      jd←'java' inv.⎕mixin 'java.util.Date'
      jd.⎕classname
java:java.util.Date

See the section on Mixins for more information.


Topic: APLX Help : Help on APL language : System Methods : ⎕MIXIN Mix another class into object
[ Previous | Next | Contents | Index | APL Home ]