Migration level

From APL Wiki
Revision as of 03:15, 4 November 2019 by Miraheze>Adám Brudzewsky (Created page with "{{Built-ins|Migration level|⎕ML|⎕EL}} or Evolution level is a number that, in Dyalog APL and APL+Win respectively, determines exact where the original NARS spe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Migration level (⎕ML, ⎕EL) or Evolution level is a number that, in Dyalog APL and APL+Win respectively, determines exact where the original NARS specification and the current APL2 implementation differ. A lower value represents a behaviour closer to NARS, while a higher the value represents a behaviour closer to APL2.

Dyalog APL currently offers the following settings:

⎕ML=0 Z←∊R Monadic is interpreted as type rather than enlist.
⎕ML=1 Default behaviour
⎕ML≤2 Z←↑R Monadic is interpreted as first rather than mix.
Z←⊃R Monadic is interpreted as mix rather than first.
Z←≡R Monadic returns a positive rather than a negative value, if its argument has non-uniform depth.
⎕ML=3 R←X⊂[K]Y Dyadic is interpreted as partition () rather than partitioned enclose.
⎕TC The order of the elements of ⎕TC is the same as in APL2.

Work-arounds

When migrating to Dyalog APL, the below drop-ins for the affected built-ins allow setting ⎕ML←1 while preserving code behaviour. It is then safe to programmatically (as shown in the rightmost column) change all occurrences of the affected built-ins with their respective covers.

Migrating from Define Then run this on all code
⎕ML=0
Epsilon←{×⎕NC'⍺':⍺∊⍵ ⋄ ⊃0⍴⊂⍵}
'''[^'']+''' '∊'⎕R'&' 'Epsilon'
⎕ML=2
UpArrow←{×⎕NC'⍺':⍺↑⍵ ⋄ ⊃⍵}
RightShoe←{×⎕NC'⍺':⍺↑⍵ ⋄ ↑⍵}
EqualUnderbar←|≡
'''[^'']+''' '↑' '⊃' '≡'⎕R'&' 'UpArrow' 'RightShoe' 'EqualUnderbar'
⎕ML=3
UpArrow←{×⎕NC'⍺':⍺↑⍵ ⋄ ⊃⍵}
RightShoe←{×⎕NC'⍺':⍺↑⍵ ⋄ ↑⍵}
EqualUnderbar←(|≡)
LeftShoe←{×⎕NC'⍺':⍺⊆⍵ ⋄ ⊂⍵}
quadTC←(⎕UCS 8 13 10)
'''[^'']+''' '↑' '⊃' '≡' '⊂' '⎕TC'⎕R'&' 'UpArrow' 'RightShoe' 'EqualUnderbar' 'LeftShoe' ' quadTC'

Alternatively, the definitions can be used directly inside the text substitutions, whereby one avoids polluting existing code with these cover names.