Dyalog 06 Notes

These are partial notes - covering the Monday to Wednesday lunch period.  They are also cryptic (I may not be able to explain them).

OO Tutorial

Definitions

Class -             abstract characteristics, can implement interfaces (describing what the class should do, not how it does it).
Instances -       tangible objects created from a specific class.  Need constructor(s) and (optionally) destructor (only one of these?)
Members    -     Code (methods)
                   -       Data (fields - both for the class and instances)
                        Properties (fields implemented via functions)
                        Method (either class (shared) or instance (instance)
Abstract methods - no code, only calling syntax
Inheritance - Avoid rewriting code; classes derive from classes
Encapsulation - Hides the underlying functionality; all ow access by declaring public (private is the default).  Dyalog doesn't handle "protected" or "friend".
Polymorphism - Same name, different code (which code is called is determined by data type)                  

Implementation

Follows C#
New keywords
New system functions and commands
)ed ○MYCLASS
:Field [... attributes ] [name]
(name is always the last)
Class versus instance methods (I'm not sure at this time I fully grasp the idea of instance methods)
Argument to setter/getters is a namespace (which has a limited set of properties)
  class.⎕NL 2 3 4 (can see inside the class) - contrast positive and negative arguments
Shared versus instance (for fields) - for example to keep <count> as a shared class field which keeps count of how many instances have been created)
To write different constructors - the determinant of which is used is the number of arguments (compared to the OO-norm of determining which constructor by datatype).  That's one way, another is to have one constructor function with a case statement..
 :Interface - defines the syntax (for example :Class car : maneouvering), several classes can share one interface.
Triggers - allow APL to react to assignments
Inheritance -   ⎕BASE
  ⎕THIS ≡ (⎕ns '').##
 :Include    equivalent to extending ⎕PATH
:Implements constructor (the location determines when the base constructor is called)
Destructor defines what happens (immediately) before the actual destruction
 'abc' ⎕FX 'tx' - adding versus replacing
⎕WX - worth taking a look at what this does.

APL Consultants Group

Casual formation - being progressed by mailing list consultant@apl.net
Dyalog casually mention "qualified" consultants.

Open Source Code Management

SALT is part of Version 11 - "undocumented" editor callback may be worth checking out (but may not be reliably present longterm)

Language Extensions (non-OOP)

  cancel←{⍵∨/⍵}
      cancel 24 36
2 3
      cancela←∘(∨/)⍨
      cancela 24 36
2 3
      rats←cancel∘(,∘1)
      rats 57
5 7
      if←{(⍺⍺⍣⍵)⍺}
      if←{(⍺⍺⍣⍵)⍺}
      on←{(⍺⍺⍣⍺)⍵}
      inv←{(⍺⍺⍣1)⍵}
      binv←⊥⍣1
      2 binv 9
1 0 0 1
      ⍝ Notice how this removes the need for pre-computing the number of "digits"

Closures

Implemented in a  mutated Version 9 interpreter (replaces an error by new capability - functions that return functions)
Two adjacent closing braces implies that a closure is being defined (not a strict definition).
Closure - a function bound with a local environment (one use - keeping global values without having global variables).  Closures appear to allow multiple arguments, which might have been more awkward without this extension.

dio←{⎕io←0 ⋄ ⍳⍵}     ⍝ Defined as a traditional d-fn
cio←{⎕io←⍵ ⋄ ⍳} 0    ⍝ Defined as a closure - performance is better, due to partial evaluation


Page updated 31 October 2006
Copyright Dogon Research 2006