Dyalog APL: Difference between revisions

Jump to navigation Jump to search
1,535 bytes added ,  18:53, 5 January 2020
no edit summary
(→‎Instruction set usage: Version numbers for x86 extension first usage)
No edit summary
(5 intermediate revisions by one other user not shown)
Line 20: Line 20:
| run online              = [https://tryapl.org/ TryAPL]
| run online              = [https://tryapl.org/ TryAPL]
}}
}}
:''For the chat bot, see [[APL Orchard#Chat bot]].''
'''Dyalog APL''', or simply '''Dyalog''', is a modern APL in the [[APL2]] tradition, first released by British company [[Dyalog Ltd.|Dyadic Systems Ltd.]] (now Dyalog Ltd.) in 1983 for the Zylog Z80 processor (the name ''Dyalog'' is a portmanteau of ''Dyadic'' and ''Zylog''). Dyalog supports several platforms and interfaces with many languages and runtimes including native [[wikipedia:Shared library|shared libraries]], [[.NET]], the [[wikipedia:Java virtual machine|JVM]], [[wikipedia:R (programming language)|R]], and [[wikipedia:Python (programming language)|Python]]. It is actively developed and has introduced many new primitives and concepts to array programming. Major categories of features introduced to APL by Dyalog are [[tacit]] programming by allowing named [[derived function]]s and later [[train]]s, lexically-scoped functional programming using [[dfn]]s, [[namespace]]s and [[object-oriented programming]], and the addition of [[leading axis theory]] and the [[Rank operator]] to the [[nested array model|nested array]] paradigm.
'''Dyalog APL''', or simply '''Dyalog''', is a modern APL in the [[APL2]] tradition, first released by British company [[Dyalog Ltd.|Dyadic Systems Ltd.]] (now Dyalog Ltd.) in 1983 for the Zylog Z80 processor (the name ''Dyalog'' is a portmanteau of ''Dyadic'' and ''Zylog''). Dyalog supports several platforms and interfaces with many languages and runtimes including native [[wikipedia:Shared library|shared libraries]], [[.NET]], the [[wikipedia:Java virtual machine|JVM]], [[wikipedia:R (programming language)|R]], and [[wikipedia:Python (programming language)|Python]]. It is actively developed and has introduced many new primitives and concepts to array programming. Major categories of features introduced to APL by Dyalog are [[tacit]] programming by allowing named [[derived function]]s and later [[train]]s, lexically-scoped functional programming using [[dfn]]s, [[namespace]]s and [[object-oriented programming]], and the addition of [[leading axis theory]] and the [[Rank operator]] to the [[nested array model|nested array]] paradigm.


Line 77: Line 78:
|                            10.1    || 2004 || July      || Multiple arguments in [[tradfn]] headers, thread tokens, 64-bit component files, value tips
|                            10.1    || 2004 || July      || Multiple arguments in [[tradfn]] headers, thread tokens, 64-bit component files, value tips
|-
|-
|                           11.0     || 2006 || October  || [[Object-oriented programming]] (classes, objects, interfaces) modelled after [[wikipedia:C-Sharp_|C#]], [[Squad indexing|Index]] (<source lang=apl inline>⌷</source>), [[Power operator]] (<source lang=apl inline>⍣</source>), [[GCD]] (<source lang=apl inline>∨</source>), [[LCM]] (<source lang=apl inline>∧</source>)
| [[Dyalog_APL_versions#11.0|11.0]]  || 2006 || October  || [[Object-oriented programming]] (classes, objects, interfaces) modelled after [[wikipedia:C-Sharp_|C#]], [[Squad indexing|Index]] (<source lang=apl inline>⌷</source>), [[Power operator]] (<source lang=apl inline>⍣</source>), [[GCD]] (<source lang=apl inline>∨</source>), [[LCM]] (<source lang=apl inline>∧</source>)
|-
|-
|                           12.0     || 2008 || August    || [[Unicode]] support (<source lang=apl inline>⎕AVU</source>, <source lang=apl inline>⎕UCS</source>), <source lang=apl inline>⎕FCOPY</source>, <source lang=apl inline>⎕FPROPS</source>
| [[Dyalog_APL_versions#12.0|12.0]]  || 2008 || August    || [[Unicode]] support (<source lang=apl inline>⎕AVU</source>, <source lang=apl inline>⎕UCS</source>), <source lang=apl inline>⎕FCOPY</source>, <source lang=apl inline>⎕FPROPS</source>
|-
|-
|                           12.1     || 2009 || November  || [[I-Beam]] (<source lang=apl inline>⌶</source>), [[Table]] (<source lang=apl inline>⍪</source>), <source lang=apl inline>⎕XML</source>, <source lang=apl inline>⎕FCHK</source>, [[User command]]s
| [[Dyalog_APL_versions#12.1|12.1]]  || 2009 || November  || [[I-Beam]] (<source lang=apl inline>⌶</source>), [[Table]] (<source lang=apl inline>⍪</source>), <source lang=apl inline>⎕XML</source>, <source lang=apl inline>⎕FCHK</source>, [[User command]]s
|-
|-
|                           13.0     || 2011 || April    || [[Left]] (<source lang=apl inline>⊣</source>), [[Right]] (<source lang=apl inline>⊢</source>), [[Variant]] (<source lang=apl inline>⍠</source>), <source lang=apl inline>⎕OPT</source>, <source lang=apl inline>⎕R</source>, <source lang=apl inline>⎕S</source>, <source lang=apl inline>⎕PROFILE</source>, <source lang=apl inline>⎕RSI</source>, [[complex number]] and [[decimal float]] support, short arguments for [[Take]], [[Drop]], and [[Squad indexing|Index]] (<source lang=apl inline>↑</source>, <source lang=apl inline>↓</source>, <source lang=apl inline>⌷</source>)
| [[Dyalog_APL_versions#13.0|13.0]]  || 2011 || April    || [[Left]] (<source lang=apl inline>⊣</source>), [[Right]] (<source lang=apl inline>⊢</source>), [[Variant]] (<source lang=apl inline>⍠</source>), <source lang=apl inline>⎕OPT</source>, <source lang=apl inline>⎕R</source>, <source lang=apl inline>⎕S</source>, <source lang=apl inline>⎕PROFILE</source>, <source lang=apl inline>⎕RSI</source>, [[complex number]] and [[decimal float]] support, short arguments for [[Take]], [[Drop]], and [[Squad indexing|Index]] (<source lang=apl inline>↑</source>, <source lang=apl inline>↓</source>, <source lang=apl inline>⌷</source>)
|-
|-
|                           13.1     || 2012 || April    || <source lang=apl inline>⎕DMX</source>, <source lang=apl inline>⎕FHIST</source>
| [[Dyalog_APL_versions#13.1|13.1]]  || 2012 || April    || <source lang=apl inline>⎕DMX</source>, <source lang=apl inline>⎕FHIST</source>
|-
|-
|                           13.2     || 2013 || January  || Array [[Editor]]
| [[Dyalog_APL_versions#13.2|13.2]]  || 2013 || January  || Array [[Editor]]
|-
|-
| [[Dyalog_APL_versions#14.0|14.0]]  || 2014 || June      || [[Train]]s, [[Tally]] (<source lang=apl inline>≢</source>), [[Key]] (<source lang=apl inline>⌸</source>), [[Rank operator]] (<source lang=apl inline>⍤</source>), multi-threading with [[future]]s and [[isolate]]s
| [[Dyalog_APL_versions#14.0|14.0]]  || 2014 || June      || [[Train]]s, [[Tally]] (<source lang=apl inline>≢</source>), [[Key]] (<source lang=apl inline>⌸</source>), [[Rank operator]] (<source lang=apl inline>⍤</source>), [[High-rank set functions|high-rank]] [[Index Of]], multi-threading with [[future]]s and [[isolate]]s
|-
|-
| [[Dyalog_APL_versions#14.1|14.1]]  || 2015 || June      || <source lang=apl inline>:Disposable</source> [[.NET]] objects and resources, gesture support, many new I-beams
| [[Dyalog_APL_versions#14.1|14.1]]  || 2015 || June      || <source lang=apl inline>:Disposable</source> [[.NET]] objects and resources, gesture support, many new I-beams
Line 255: Line 256:
| <source lang=apl inline>f∘g</source>  ||colspan=2| [[Beside]]
| <source lang=apl inline>f∘g</source>  ||colspan=2| [[Beside]]
|-
|-
| <source lang=apl inline>f⍤B</source>  ||colspan=2| [[Rank]]
| <source lang=apl inline>f⍤B</source>  ||colspan=2| [[Rank operator|Rank]]
|-
|-
| <source lang=apl inline>f⍤g</source>  ||colspan=2| [[Atop]]
| <source lang=apl inline>f⍤g</source>  ||colspan=2| [[Atop]]
Line 277: Line 278:


== Implementation ==
== Implementation ==
Dyalog APL is implemented primarily in [[wikipedia:C (programming language)|C]] with some parts implemented in [[wikipedia:C++|C++]] in order to use [[wikipedia:C++#Templates|templates]]. C [[wikipedia:Intrinsic function|intrinsics]] are used to access instruction set extensions. Some architecture-specific [[wikipedia:Assembly language|assembly]], both compiled separately and inline from C, is used for functionality like [[wikipedia:Status register|exception flags]] which is not easily accessible in C. Prior to [[Dyalog APL versions#17.0|version 17.0]], assembly was also used for vectorized arithmetic. In 17.0, this code was replaced by a new C++ implementation.


=== Internal types ===
=== Internal types ===
Line 287: Line 290:
* 8-byte [[wikipedia:IEEE 754|double]]
* 8-byte [[wikipedia:IEEE 754|double]]
* 16-byte [[complex]] (one double for each component)
* 16-byte [[complex]] (one double for each component)
* 16-byte decimal float ([[wikipedia:Binary integer decimal|BID]] or [[wikipedia:Densely packed decimal|DPD]])
* 16-byte decimal float "decf" ([[wikipedia:Binary integer decimal|BID]] or [[wikipedia:Densely packed decimal|DPD]])
 
[[Character]] encodings differ for classic and unicode interpreters: classic interpreters use a custom 1-byte encoding for all characters, and are limited to a 256-character set, while characters in unicode interpreters are 1-, 2-, or 4-byte unsigned unicode [[wikipedia:code point|code point]] values.
 
[[Nested]] and [[mixed array]]s (that is, [[pointer array]]s) are always stored as arrays of pointers, while [[simple array|simple]] numeric or character arrays are always stored using one of the above types. For both numbers and characters, an array may be represented using any type that can contain all the values. The interpreter may reduce the type of an array to the minimum possible ("squeeze" the array) during execution.


Character encodings differ for classic and unicode interpreters: classic interpreters use a custom 1-byte encoding for all characters, and are limited to a 256-character set, while unicode characters are 1-, 2-, or 4-byte unsigned [[wikipedia:code point|code point]] values.
Because there is no [[complex]] representation using decimal floats for the components, arrays containing both decimal floats and complex numbers have no common representation. Dyalog converts such arrays to complex numbers, resulting in a loss of precision for decf elements.


=== Instruction set usage ===
=== Instruction set usage ===
Line 299: Line 306:
* As of version 17.1, POWER7 and above are supported. Support for older systems is dropped because Dyalog compiles separate binaries for each POWER architecture.
* As of version 17.1, POWER7 and above are supported. Support for older systems is dropped because Dyalog compiles separate binaries for each POWER architecture.


In Dyalog 17.0, the code for vectorised [[scalar function]]s was unified and extended to allow Intel [[wikipedia:AVX2|AVX2]] and ARM NEON in addition to Intel [[wikipedia:SSE2|SSE2]] and [[wikipedia:SSE4.1|SSE4.1]], and AltiVec VMX for IBM POWER. This code is also used for operations involving the scalar dyadics [[Plus]], [[Minus]], [[Times]], [[Divide]], [[Maximum]], [[Minimum]], and [[comparison function]]s, as well as some functions derived from operators applied to these functions, such as the [[Outer Product]] and [[Inner Product]].
In Dyalog 17.0, the code for vectorized [[scalar function]]s was unified and extended to allow Intel [[wikipedia:AVX2|AVX2]] and ARM NEON in addition to Intel [[wikipedia:SSE2|SSE2]] and [[wikipedia:SSE4.1|SSE4.1]], and AltiVec VMX for IBM POWER. This code is also used for operations involving the scalar dyadics [[Plus]], [[Minus]], [[Times]], [[Divide]], [[Maximum]], [[Minimum]], and [[comparison function]]s, as well as some functions derived from operators applied to these functions, such as the [[Outer Product]] and [[Inner Product]].


Dyalog also uses many other x86 extensions:
Dyalog also uses many other x86 extensions:

Navigation menu