object orientation in dyalog apl

94
Object Orientation in Dyalog APL Implementation details V1.01

Upload: dutch

Post on 12-Jan-2016

34 views

Category:

Documents


0 download

DESCRIPTION

Object Orientation in Dyalog APL. Implementation details V1.01. Implementation details. Dyalog implemented Object Orientation (OO) in APL. New territory was uncovered when venturing into OO. In keeping with the dynamic nature of APL a lot of questions were raised. And many were answered. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Object Orientation in Dyalog APL

Object Orientationin Dyalog APL

Implementation detailsV1.01

Page 2: Object Orientation in Dyalog APL

Dyalog implemented Object Orientation (OO) in APL.

New territory was uncovered when venturing into OO.

In keeping with the dynamic nature of APL a lot of questions were raised.

And many were answered.

Implementation details

Page 3: Object Orientation in Dyalog APL

Classes' system functions/commands

All Interfaces, Classes & some Namespaces (ICN) come in scripted form.

• ⎕SRC: Just like NR returns the ⎕representation of a function in nested form, SRC returns the representation of an ICN in ⎕

nested form.

• ⎕FIX: Just like FX creates a function, FIX ⎕ ⎕creates an ICN.

• )ED ∘Interf /○Cl/ Ns⍟

Implementation details

Page 4: Object Orientation in Dyalog APL

Classes' system functions/commands

• monadic CLASS returns the tree of references⎕• dyadic CLASS casts an instance into another ⎕

ns• )CLASSES lists classes in the namespace• :Implements identifies what it implements• ⎕DF change the display form of a NS• )INTERFACES lists all interfaces in the

current namespace

Implementation details

Page 5: Object Orientation in Dyalog APL

Classes:A class can implement one or more

interfaces.An interface describes what it should

do.The class describes how it should be

done.

Implementation details

Page 6: Object Orientation in Dyalog APL

This maneuvering interface describes what has to be done with a machine:

)ed ∘maneuvering

It does NOT specify how it should be done.

Implementation details

Page 7: Object Orientation in Dyalog APL

This car class implements maneuvering:

VW← new Car⎕ VW.GasPedal 60 Going up to 60 (maneuvering class VW).Steer 140⎕Heading NW (maneuvering class VW).Accellerate 120⎕Going up to 120 VW.GasPedal 100 Going down to 100 VW.BreakPedal 1 Breaking...

Implementation details

Page 8: Object Orientation in Dyalog APL

This plane class implements maneuvering:

C172← new Plane⎕ C172.Stick 23 Heading 20 C172.Handle 200 Going up to 200 C172.Stick 23 11 Climbing, Heading 20 (maneuvering class C172).Steer 210⎕Heading 210 (maneuvering class C172).SlowDown 20⎕Flaps 20 degrees

Implementation details

Page 9: Object Orientation in Dyalog APL

Members' system functions/commandsMembers are Fields (variables), Methods

(functions), properties and other classes.

• ⎕INSTANCES lists the instances of a class• ⎕NEW creates an instance• Special Property cases• Triggers

Implementation details

Page 10: Object Orientation in Dyalog APL

PropertiesIn C# they are implemented as a pair of

functions. In APL the 'name←' case is handled naturally. It

is called the SIMPLE case and is the default.A second case where indexing is made using

any object (as opposed to numbers) is also handled easily. This is the KEYED case.

The array nature of APL introduced a notion of NUMBERED property. This is the third case.

Implementation details

Page 11: Object Orientation in Dyalog APL

Implementation detailsProperties: SIMPLE caseWhen a property is set, its SET function is called.When retrieved, its GETfunction is called.The argument is a namespacecontaining the name of theproperty (Name) and its value(NewValue).

Page 12: Object Orientation in Dyalog APL

Properties: KEYED case‘pa’ also contains the indices

of the property (Indexers).The property MUST be used

with [brackets] and their contents cannot be elided.

Their shape must conform to APL rules for assignment and result.

Implementation details

Page 13: Object Orientation in Dyalog APL

Properties: NUMBERED case

The set/get function call is made, ONCE per index.

‘pa’ also contains the index to deal with (Indexers).

It may be used with indices. The SHAPE function is used to check and generate indices.

Their shape must conform to APL rules for assignment and result.

Implementation details

Page 14: Object Orientation in Dyalog APL

Default PropertiesThere can be only one.If a default property exist, [indexing] can be

done directly on the instance. Doinginstance[index] is the same as instance.defProp[index]

If a property is the default then using “squad indexing” applies to the whole property

Implementation details

Page 15: Object Orientation in Dyalog APL

Multiple PropertiesIf several properties are similar the

definition statement may include several names separated by commas, like this:

:Property P1,P2,P3

The Get/Set functions’ argument will contain the name in ‘Name’ (as in arg.Name)

Implementation details

Page 16: Object Orientation in Dyalog APL

Triggers t← NEW trigger1 ('Dan' ⎕'Baronet')

Full name is Dan BaronetFull name is Dan Baronet t.FirstName←'Daniel'Full name is Daniel Baronet

Implementation details

Page 17: Object Orientation in Dyalog APL

Inheritance: new system functions/commands

• :Base used to call base class constructor• ⎕BASE used to call base class functions• override/able• Destructors are called when the instance is destroyed• ⎕NC/ NL have been extended⎕• ⎕THIS is the same as ( NS'').##⎕• :implements, :access• can be GUI based (ex: :Class F: ‘form’)• :include

Implementation details

Page 18: Object Orientation in Dyalog APL

pet← NEW Collie ‘Rex’⎕pet. nl -2⎕

Name Nlegs Sounds Typepet.(Name Type)

Rex canis familiaris

Implementation details: :Base

Page 19: Object Orientation in Dyalog APL

⎕Base is used to call base function like :base is used to call the constructor with an argument.This is used when the base function is shadowed by a class member. As in

s1← new square⎕s1.surface 20

400

Implementation details: Base⎕

Page 20: Object Orientation in Dyalog APL

Override and overridable

These concepts allow a base class code to be overridden.

The following slides will explain this in more details.

Implementation details

Page 21: Object Orientation in Dyalog APL

Non-Based classes

⍝ M1 calls its own M2:( NEW A).M1⎕

I am A

⍝ M1 calls its own M2:( NEW B).M1⎕

I am B

Page 22: Object Orientation in Dyalog APL

Non-Based classes

⍝ M1 calls its own M2:( NEW A).M1⎕

I am A

⍝ M1 calls its own M2:( NEW B).M1⎕

I am B

M1

M2 M2‘I am A’

M1

M2 M2‘I am B’

Class A Class B

Page 23: Object Orientation in Dyalog APL

Based classes

⍝ M1 calls its own M2:( NEW B).M1⎕

I am A

Page 24: Object Orientation in Dyalog APL

Based classes

⍝ M1 calls its own M2:( NEW B).M1⎕

I am A

M1

M2 M2‘I am A’

There is no M1 in Bso A’s (on which B is based) M1 is used

M2‘I am B’

Class A Class B: A

Page 25: Object Orientation in Dyalog APL

Overridden classes

⍝ M1 calls its own M2 because ⍝ it has not been overridden:

( NEW B).M1⎕I am A

Page 26: Object Orientation in Dyalog APL

Overridden classes

⍝ M1 calls its own M2:( NEW B).M1⎕

I am A

M1

M2 M2‘I am A’

There is no M1 in Bso A’s (on which B is based) M1 is used

M2‘I am B’

Class A Class B: A

Page 27: Object Orientation in Dyalog APL

Overridden classes

⍝ M1 calls B’s M2 because ⍝ it has been overridden:

( NEW B).M1⎕I am B

Page 28: Object Orientation in Dyalog APL

M2‘I am B’

Overridden classes

⍝ M1 calls B’s M2:( NEW B).M1⎕

I am B

M1

M2 M2‘I am A’

Class A

There is no M1 in Bso A’s (on which B is based) M1 is used

Class B: A

Page 29: Object Orientation in Dyalog APL

Implementation detailsDestructorsThey are used to clean-up

after an instance is destroyed:

kk← new life ‘Kong'⎕ King Kong is born

)erase kk Kong is dead, long live the

king.

Page 30: Object Orientation in Dyalog APL

Implementation details: NC/ NL ⎕ ⎕⎕NC/ NL extensions⎕

Those 2 system functions have been extended to deal with the new objects.

Since classes and instances are a type of namespace their basic classification is 9:⎕NC ‘myClass’

9To find their sub-class they need to be enclosed:⎕NC ⊂‘myClass’

9.4

Page 31: Object Orientation in Dyalog APL

⎕NC/ NL extensions⎕

⎕NL has also been extended to report all objects of a given sub-class:⍴⍴⎕NL 9.4

2

Furthermore, if one of the argument to NL is ⎕negative the result is returned in vector format:⍴⍴⎕NL -9.4

1

Implementation details: NC/ NL⎕ ⎕

Page 32: Object Orientation in Dyalog APL

⎕NC/ NL extensions⎕

⎕NL and NC are symmetric such that⎕

n∊ NC NL n⎕ ⎕and

vn∊ NL NC¨vn vn is a list of names⎕ ⎕ ⍝

Implementation details: NC/ NL⎕ ⎕

Page 33: Object Orientation in Dyalog APL

⎕NC/ NL extensions⎕

⎕NL and NC also apply to variables and functions.⎕The complete list is:

2 3/4 9 n.1 Variable Traditional fn/op NS created by

NS ⎕ n.2 Field D-fns or –op Instance (could be form) n.3 Property Derived/Primitive - n.4 - - Class n.5 - - Interface n.6 External/shared External External Class

n.7 - - External Interface

Implementation details: NC/ NL⎕ ⎕

Page 34: Object Orientation in Dyalog APL

To see usevars or fields: )varsfns or methods:

)fns/methodsclasses: )classesinterfaces: )interfacesevents: )eventsproperties: )props

Implementation details: System commands

Page 35: Object Orientation in Dyalog APL

Implementation details: NC/ NL ⎕ ⎕⎕NC/ NL extensions⎕

⎕NL also includes instance members when used with a negative argument

instance. NL -2⎕ .2 report all fields⍝

Page 36: Object Orientation in Dyalog APL

Types of Namespaces and their NC⎕

The first two already existed in V10• Regular NS 9.1• Forms 9.2• Instances 9.2 (NOT 9.3!)• Classes 9.4• Interfaces 9.5

Implementation details

Page 37: Object Orientation in Dyalog APL

Implementation details: DF⎕

The default display form of a namespace is its path:←⎕ 't1.s1' NS ''⎕

#.t1.s1

We can change this using DF:⎕t1.s1. df '(S1: son of t1)'⎕t1.s1

(S1: son of t1)

Page 38: Object Orientation in Dyalog APL

Display form of namespaces

abc←t1.s1 even if assigned a new ⍝name:abc what does this look like?⍝

(S1: son of t1)abc≡t1.s1 it “remembers” its ⍝reference

1≡⍴⍬ abc it is still just a ref⍝

1⍴⍕abc its display has a length⍝

15

Page 39: Object Orientation in Dyalog APL

Contents of namespacest1.s1.v11←’var’ If we change the ⍝t1.s1. fx ‘f1’ ‘...’ contents of s1:⎕ ⍝,t1.s1. nl 2 3⎕

f1 v11,abc. nl 2 3⎕ abc will “see” it⍝

f1 v11⎕NC ’abc’ ‘t1’ ‘t1.s1’

9.1 9.1 9.1

Page 40: Object Orientation in Dyalog APL

Contents of namespacesTo get a distinct copy of t1.s1 we need to

doabc← NS OR 't1.s1'⎕ ⎕,abc. NL 2 3 everything is ⎕ ⍝ copied

f1 v11abc even its name⍝

(S1: son of t1)abc≡t1.s1 but they’re different⍝

0abc. df ‘I am ABC’ ⋄ abc⎕

I am ABC

Page 41: Object Orientation in Dyalog APL

Contents of namespacesOutside world (e.g. WS) abc

I am ABC

∇f1...∇

v11←’var’

abc. NL 2 3⎕

f1v11

Page 42: Object Orientation in Dyalog APL

Contents of namespacesabc

I am ABC

∇f1...∇

v11←’var’

∇tx←{,⍵} ∇

You can addto a namespace:

tx←{, }⍵ ‘abc’ ns ‘tx’⎕

and <tx> appearswithout ‘v11’ or <f1>going away.

Page 43: Object Orientation in Dyalog APL

Contents of namespacesabc

#.[Namespace]

∇tx←{,⍵} ∇

But if you use ← instead:

tx←{, }⍵ abc← ns 'tx'⎕

<tx> appears in‘abc’ alone andthe display form is reset

Page 44: Object Orientation in Dyalog APL

Display form of a Form

The default display form of a Form is its path, just like a regular namespace:+'F1' WC 'form'⎕

#.F1

We can change this using DF:⎕F1. df '<F1 is in great form>'⎕F1

<F1 is in great form>

Page 45: Object Orientation in Dyalog APL

Display form of a form ⍝ we can add items to it:

‘F1.b1’ wc ‘button’⎕‘e2’ F1. wc ‘edit’⎕⎕nc ‘F1’ ‘F1.b1’ ‘F1.e2’

9.2 9.2 9.2 ⍝ we have 3 instances of built-in APL

formsF1.e2 F1 each with its own name⍝

#.F1.e2 <F1 is in great form>

Page 46: Object Orientation in Dyalog APL

Contents of a formThe form contains 2

objects:⍴ ←⎕ F1. nl 2 3 9⎕

b1e22 2⎕nc ‘F1.b1’

9F1. nc ‘Caption’⎕

0

<F1 is in great form>

e2

Page 47: Object Orientation in Dyalog APL

Contents of a formA form is pretty much like a namespace.It can contain variables and functions.

F1.v1←’some var’F1. fx ‘f1’ ‘whatever’⎕F1. nl 2 3 these are POSITIVE ⎕ ⍝numbers

f1v1

Those are the items WE have added.

Page 48: Object Orientation in Dyalog APL

Contents of a formThe form now contains 4 objects:

⍴ ←⎕ F1. nl 2 3 9⎕b1e2f1v14 2⎕nc ‘F1.b1’

9

<F1 is in great form>

e2

∇ f1whatever∇

v1←’some var’

Page 49: Object Orientation in Dyalog APL

Contents of a formBUT a form also has properties and methods:

F1. wx←1 to be able to see them⎕ ⍝⍴ ←⎕ F1. nl -2 3 include internal items⎕ ⍝

Accelerator ... Caption ... YRange69

F1. nc ⎕ ⊂’Caption’ Caption is external⍝¯2.6The new 65 items are the only visible members

inside the form. They do NOT appear in nl +2 ⎕3

Page 50: Object Orientation in Dyalog APL

Contents of a formThe form contains 4

external objects:⍴ ←⎕ F1. nl -2 3⎕

4

<F1 is in great form>

∇f1∇

v1

e2

[]WX=0

Page 51: Object Orientation in Dyalog APL

The form contains 69 total objects:⍴ ←⎕ F1. nl -2 3⎕

Accelerator ... Caption ... YRange

69

[]WX=1

Contents of a form

<F1 is in great form>

∇f1∇

v1

e2

<F1 is in great form>

∇f1∇

v1

e2

AcceleratorCaption

HintWait

HelpButton

Size Step Xrange

Picture Posn PropList Range Redraw

Border BCol

AcceptFiles Active

YRange

VScroll

Picture

PosnMethodList MinButton Moveable

CursorObj Data Detach

Page 52: Object Orientation in Dyalog APL

Contents of a formThe form has 2 types of functions and

variables:

1. Those internal and specific to its type2. Those external, those we add

The 1st ones can be listed with a NEGATIVE NL argument ONLY⎕

The 2nd ones can be listed with a POSITIVE NL argument. ⎕

⎕NL- includes both types of elements.

Page 53: Object Orientation in Dyalog APL

Contents of namespaces

All namespaces have a common structure

• They inherit system variables• The system variables exist both internally

AND externally

Page 54: Object Orientation in Dyalog APL

Contents of a formIf we redefine the form all external objects

disappear:+‘F1’ wc’form’⎕

#.F1⍴F1. nl 2 3⎕

0 0⍴F1. nl-2 3⎕

65

#.F1

Page 55: Object Orientation in Dyalog APL

Contents of a classOutside world (e.g. WS) ShrIns

Classes are a different kind of namespace but they behave identically.

⍝ NO external object ⍴ShrIns. NL 2 3⎕0 0

Page 56: Object Orientation in Dyalog APL

Contents of a classOutside world (e.g. WS) ShrIns

Master Share/instance

∇MS1∇

FS1 (no value)

ShrIns. NL -2 3⎕FS1 MS1

The private members cannot be seen or accessed from outside.

∇MS0∇

FS0 (no value)

Page 57: Object Orientation in Dyalog APL

Contents of a classOutside world (e.g. WS) ShrIns

Master Share/instance

∇MS1∇

FS1 (no value)

You can add items “outside” a class: tx←{, }⍵ ‘ShrIns’ ns ‘tx’⎕ ShrIns.v11←32and they appearwithout anything elsegoing away.

v11←32

∇tx←{,⍵}∇

Page 58: Object Orientation in Dyalog APL

Contents of a classOutside world (e.g. WS) ShrIns

Master Share/instance

∇MS1∇

FS1 (no value)

ShrIns. NC 2 3⎕txv11 ShrIns. nc-2 3⎕ tx v11 FS1 MS1

v11←32

∇tx←{,⍵}∇

Page 59: Object Orientation in Dyalog APL

Contents of an instanceOutside world (e.g. WS) SI1

#.[ShrIns]

∇MS1∇

FS1(no value)

SI1← new ShrIns⎕ ⍴SI1. NL 3 2⎕0 0 SI1. NL -3 2⎕ FI1 FS1 MI1 MS1

The shared members are visible through the instance.

∇MI1∇

FI1(no value)

Instancemembers

Classmembers

Page 60: Object Orientation in Dyalog APL

Contents of an interfaceOutside world (e.g. WS)

)ed maneuvering∘

⍴maneuvering. NC -2 3⎕0 maneuvering.v11←12 maneuvering. NC -2 3⎕v11

Page 61: Object Orientation in Dyalog APL

Contents of an interfaceOutside world (e.g. WS)

The methods in the interface can only be seen when exposed through the dyadic CLASS ⎕system function:

VW← new Car⎕ (VW class maneuvering). nl -3⎕ ⎕Accellerate SlowDown Steer

Page 62: Object Orientation in Dyalog APL

Contents of all namespaces

This concept of internal/external names is important.

Assuming we have all types of namespaces as follows:ns← ns 'v1' 'f1'⎕fo← new ⎕ ⊂'form'in1← new cl1⎕all←ns,fo,cl1,in1,int1

then doing⍴¨all. nl⎕ ⊂-2 3 will show⍝

2 65 1 2 0

Page 63: Object Orientation in Dyalog APL

Contents of all namespacesThis concept of internal/external names is important.

Adding 1 external item to each namespace:

⍴¨all.⎕nl⊂-2 3 ⍝ will show2 65 1 2 0

all.X←⍳5⍴¨all.⎕nl⊂-2 3

3 66 2 3 1

Page 64: Object Orientation in Dyalog APL

:IncludeThis statement is

used when wanting to include CODE (not data) into a class.

This may be because the code to include is common.

Page 65: Object Orientation in Dyalog APL

Implementation details summary

• Many new system commands & fns• Interfaces show how it is done• Numbered Properties are implemented in

a special manner in APL• Triggers offer lightweight properties• ⎕NL/ NC have been extended⎕• The notion of external names is important• Inclusion of common code is possible

Page 66: Object Orientation in Dyalog APL

End of implementation details

QUESTIONS

?

Page 67: Object Orientation in Dyalog APL
Page 68: Object Orientation in Dyalog APL

Complex ClassThis class is used to create

complex numbers. It can perform most simple

math operations on them.

This class has • 2 public instance fields• 1 public shared field• 2 private fields• 5 instance functions• ...

Page 69: Object Orientation in Dyalog APL

Complex ClassThis class also has • 5 shared functions

These perform the basic operations: + - × ÷ *

Page 70: Object Orientation in Dyalog APL

Complex ClassThis class also has • 2 constructors and• 2 private functionsone of which is a

trigger for when one of the fields is modified

Page 71: Object Orientation in Dyalog APL

Keyed component file

The idea is to have a file whose components are accessed by key instead of a number.

Sort offile.Read ‘key’

Page 72: Object Orientation in Dyalog APL

Keyed component fileSince it is made from a

component file it might be better to define a component file class.

Like this →This class ties a file,

creating it if necessary, and unties it (and destroys it if it was temporary) upon deleting the instance

Page 73: Object Orientation in Dyalog APL
Page 74: Object Orientation in Dyalog APL

.Net and other goodies

In addition to the classes which you can write in APL, version 11.0 allows you to work with:

• Dyalog GUI classes, including OLE Servers and and OLE Controls (ActiveX components)

• Microsoft.Net classes

Page 75: Object Orientation in Dyalog APL

.Net and other goodies

In version 11.0, these classes can be used in exactly the same way as instances of classes which have been implemented in APL.

You create instances of them with NEW, and ⎕you can manipulate the public properties, methods and events which they expose (but unlike APL classes, you cannot see or modify the implementation).

Page 76: Object Orientation in Dyalog APL

Forms and more via NEW⎕• It is possible to create forms using new:⎕

f1← NEW 'form‘ ((‘caption’ ‘MyForm’)('size' (12 16))⎕Note that the class name for built-in GUI objects is

provided as a string rather than as a reference to a name in the workspace.

• You can create OLE controls with new too:⎕xl← NEW 'OleClient‘ (⎕ ⊂'ClassName‘ 'Excel.Application')

Page 77: Object Orientation in Dyalog APL

⎕WX

This system function eXposes Window’s interface:

0= do NOT expose anything+1= expose names and report in NL ⎕

with negative argument, use V10 syntax where properties are treated as functions (e.g. Sheet.(Item 3)...)

+2= use new V11 syntax (e.g. Sheet[3]...)

Page 78: Object Orientation in Dyalog APL

xl← NEW 'OleClient‘ (⎕ ⊂'ClassName‘ 'Excel.Application')

⎕wx allows to use V10 syntax or the new V11 syntax:xl. wx←1 use V10 form⎕ ⍝xl. ActiveWorkbook.Sheets.(Item 1).Namexl. wx←3 use V11 form⎕ ⍝xl.ActiveWorkbook.Sheets[⊂’Sheet2'].Index

⎕WX

Page 79: Object Orientation in Dyalog APL

.Net and other goodiesExample:standardize

dialog boxesf1← NEW Dialog ('Hello ⎕

World' (50 250) )⍬

Note how the class is based on ‘Form’ (a string) and not Form (a name)

You can do fm← NEW ‘form’ ...⎕

Page 80: Object Orientation in Dyalog APL

.Net and other goodies.Net utilitiesThere is a lot of utilities out there that can be used in APL.For example, the Date/Time utilities found in the .Net

DateTime class.They are found in the System namespace.To be able to use the DateTime class you must indicate to APL

that it resides in the System namespace with USING:⎕

⎕USING←’System’now← new DateTime ts⎕ ⎕now let’s see its display form:⍝

2007/10/01 21:47:08⎕nc ‘now’

9

Page 81: Object Orientation in Dyalog APL

.Net and other goodies.Net for othersTo allow other languages to use your code you

should organize your classes in namespaces:

WS

NS1

NS2

ClassA ClassB ClassC

ClassX ClassY

Page 82: Object Orientation in Dyalog APL

.Net and other goodies.Net for othersTo allow other languages to use your

code you• declare how it works

using the :Signaturestatement

• export it through theFile/Export/.Net DLLmenu item

Page 83: Object Orientation in Dyalog APL

:Signature statementThis statement is used for the outside world where type

is important.It is made up of

:Signature [rt←] fnname [at1 [name1] [,ng2 [,...] ] ]rt← is the return type. If present it MUST be followed by ←fnname is the name of the function as seen from outside. It does

not have to match the function name. This MUST be there.at1 is the 1st argument type, if presentname1 is the name of the 1st argument as seen from outside. If

elided the DLL documentation will skip it and only show the type,ng2 is the same at/name group for the 2nd argument. If

present, the comma MUST be there as it delimits groups

,... same for the other arguments

Page 84: Object Orientation in Dyalog APL

.Net and other goodies.Net for othersHere’s how a C# program would use this

program:

using System;using APLClasses; // the namespace in which our

classpublic class MainClass { // is found public static void Main() { Primitives apl = new Primitives(); // the APL class int[] rslt = apl.GenIndices(10); // THE call for (int i=0;i<rslt.Length;i++) Console.WriteLine(rslt[i]);} }

Page 85: Object Orientation in Dyalog APL

.Net and other goodies.Net for othersHere’s how another APL program would use

this program:

⎕using←'APLclasses,c:\...\apl.dll'

pr← NEW Primitives⎕ pr.GenIndices 101 2 3 4 5 6 7 8 9 10

Page 86: Object Orientation in Dyalog APL

.Net and other goodiesWeb services can be written using APLScript, the scripting version of

Dyalog APL, where logic is separated from page layout

• in ASMX files and ASPX filesor• in workspaces “behind”

Page 87: Object Orientation in Dyalog APL

.Net and other goodiesExample of Web services written in APLScript

Page 88: Object Orientation in Dyalog APL

.Net and other goodiesExample of Web services written in APLScript

Page 89: Object Orientation in Dyalog APL

.Net and other goodies

With ASPX files:

Page 90: Object Orientation in Dyalog APL

:Using:Using vs USING⎕

:Using X is akin to USING,←'X'⎕It appends X to USING except when no ⎕

argument is supplied where it means “←0⍴⊂ ”⍬

In a script/class it is necessary to determine the base class/interfaces

Page 91: Object Orientation in Dyalog APL

Namespaces in script form

)ed ⍟name will edit a new name using the same source format as classes and interfaces.

The source can then be retrieved using SRC and ⎕fixed using FIX.⎕

Namespaces can have a source

Page 92: Object Orientation in Dyalog APL

Overloading• Primitives cannot be overloaded by APL

classes but some .Net classes are.• Ex: DateTime objects can be compared using

=, >, etc. sorted using ‘grade up’ or added to TimeSpans using +.⎕using←'System'

d1← new DateTime ts assume it is 2007/10/10 ⎕ ⎕ ⍝19:12:01

d2← new DateTime (2007 10 16)⎕ t1← new TimeSpan (7 2 0 0) 7 days, 2 hours⎕ ⍝ +d3←d1-t12007/10/03 17:12:01 d1<d2,d31 0

Page 93: Object Orientation in Dyalog APL

There are many advantages to using OO languages over procedural languages:

• ease of modification• reduced maintenance costs• easier to model• can speed up development time• etc.

Conclusion

Page 94: Object Orientation in Dyalog APL

This doesn't mean you have to rewrite everything! But you are now competitive with the other guys.

If someone tells you "you can't do OO or .Net" you can now say "We can!"