Function-operator overloading: Difference between revisions

Jump to navigation Jump to search
apl+
(Term is still fairly common today.)
(apl+)
 
Line 1: Line 1:
In [[APL syntax]], '''function-operator overloading''' (archaic epithet: '''schizophrenia'''<ref>The term ''schizophrenia'' used to be associated with [[wikipedia:split personality|''split personality'']] by the general population but that usage went into decline when it became known as a separate disorder. The term was used for duality of programming language constructs as early as 1978, for example in [https://dl.acm.org/doi/10.1145/800025.1198354 the transcript] of [[Alan Perlis]]'s [[HOPL]] I entry on [[wikipedia:ALGOL 58|ALGOL 58]]. The informal usage lives on in APL circles when referring to the exhibited behaviour in primitives affected by function-operator overloading.</ref>) is the practice of using a single [[glyph]] for both a [[primitive function]] and a [[primitive operator]], which is then characterised as a '''hybrid''' primitive. Dialects with this feature include [[Dyalog APL]], [[NARS2000]], [[A+]], and [[GNU APL]]. Most commonly it refers to one of the slash glyphs <syntaxhighlight lang=apl inline>/⌿\⍀</syntaxhighlight> (for example, <syntaxhighlight lang=apl inline>/</syntaxhighlight> is both [[Replicate]] and [[Reduce]]), and dialects [[APL2]] and [[APLX]], which [[Replicate#Operator or function?|define Replicate and Expand to be operators]], don't use it. [[Assignment]] may also be handled in a similar manner because ordinary assignment has the form of a [[dyadic function]] while [[modified assignment]] works like a [[monadic operator]] applied dyadically. Overloading may apply only to the glyphs themselves, or to their values and derivations as well: for example, in [[Dyalog APL]] the assignments <syntaxhighlight lang=apl inline>r←/</syntaxhighlight> and even <syntaxhighlight lang=apl inline>r←/[3]</syntaxhighlight> cause <syntaxhighlight lang=apl inline>r</syntaxhighlight> to exhibit overloading.
In [[APL syntax]], '''function-operator overloading''' (archaic epithet: '''schizophrenia'''<ref>The term ''schizophrenia'' used to be associated with [[wikipedia:split personality|''split personality'']] by the general population but that usage went into decline when it became known as a separate disorder. The term was used for duality of programming language constructs as early as 1978, for example in [https://dl.acm.org/doi/10.1145/800025.1198354 the transcript] of [[Alan Perlis]]'s [[HOPL]] I entry on [[wikipedia:ALGOL 58|ALGOL 58]]. The informal usage lives on in APL circles when referring to the exhibited behaviour in primitives affected by function-operator overloading.</ref>) is the practice of using a single [[glyph]] for both a [[primitive function]] and a [[primitive operator]], which is then characterised as a '''hybrid''' primitive. Dialects with this feature include [[Dyalog APL]], [[NARS2000]], [[A+]], [[GNU APL]], and previously [[APL+Win]]. Most commonly it refers to one of the slash glyphs <syntaxhighlight lang=apl inline>/⌿\⍀</syntaxhighlight> (for example, <syntaxhighlight lang=apl inline>/</syntaxhighlight> is both [[Replicate]] and [[Reduce]]), and dialects [[APL2]] and [[APLX]], which [[Replicate#Operator or function?|define Replicate and Expand to be operators]], don't use it. [[Assignment]] may also be handled in a similar manner because ordinary assignment has the form of a [[dyadic function]] while [[modified assignment]] works like a [[monadic operator]] applied dyadically. Overloading may apply only to the glyphs themselves, or to their values and derivations as well: for example, in [[Dyalog APL]] the assignments <syntaxhighlight lang=apl inline>r←/</syntaxhighlight> and even <syntaxhighlight lang=apl inline>r←/[3]</syntaxhighlight> cause <syntaxhighlight lang=apl inline>r</syntaxhighlight> to exhibit overloading.
== Occurrence ==
== Occurrence ==
The following glyphs may be subject to function-operator overloading:
The following glyphs may be subject to function-operator overloading:
Line 35: Line 35:
4
4
</syntaxhighlight>{{Works in|[[Dyalog APL]], with version [[Dyalog APL 18.0|18.0]] for [[Atop]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]], with version [[Dyalog APL 18.0|18.0]] for [[Atop]]}}
None of the above techniques are possible in [[APL+Win]], so [[system function]]s <syntaxhighlight lang=apl inline>⎕REPL</syntaxhighlight> and <syntaxhighlight lang=apl inline>⎕COMPRESS</syntaxhighlight> are provided instead. APL+Win previously allowed parenthesising a hybrid (for example <syntaxhighlight lang=apl inline>(/)</syntaxhighlight>) to force function interpretation, although this is disabled when the [[evolution level]] is set to maximise [[APL2]]-compatibility.


== References ==
== References ==

Navigation menu