Magic function: Difference between revisions
No edit summary |
m (add navbox) |
||
Line 10: | Line 10: | ||
[[Category:Implementation]] | [[Category:Implementation]] | ||
{{APL development}} |
Latest revision as of 08:47, 7 August 2023
In APL implementation, magic functions are a technique that allows parts of an interpreter written in a language such as C to be implemented in APL. Much like APL code stored in an APL string is evaluated during the execution of the Execute primitive, a magic function evaluates APL code stored in a C (or other implementation language) string while executing a primitive or derived function. Magic functions can allow APL implementers to work more quickly by using a higher-level language, and can even improve performance as APL allows the programmer to more easily access fast primitive implementations.[1] Often they are used for testing new functionality or implementation techniques, as they can be easily changed during prototyping, and translated back to the implementation language after the code has stabilized.
Magic functions are not the only way to implement parts of an interpreter in APL: while a magic function is written as part of the interpreter's source code and called during execution, it may also be possible to define parts of the interpreter using external APL code executed at startup. Functionality like user commands is often written in APL in this way, and ngn/apl even uses this technique to implement primitives, as it allows primitives to be freely reassigned.
During the time we were implementing the very first version of Dyalog, a friend, who was not a programmer, asked me how much of it was coded in APL. I thought he was bonkers.
We now have exactly this internal "magic function" prototyping facility.
References
- ↑ Roger Hui. "In Praise of Magic Functions: Part I". Dyalog blog. 2015-06-22.
- ↑ John Scholes. "Declarative Programming" in the dfns workspace.
APL development [edit] | |
---|---|
Interface | Session ∙ Typing glyphs (on Linux) ∙ Fonts ∙ Text editors |
Publications | Introductions ∙ Learning resources ∙ Simple examples ∙ Advanced examples ∙ Mnemonics ∙ ISO 8485:1989 ∙ ISO/IEC 13751:2001 ∙ A Dictionary of APL ∙ Case studies ∙ Documentation suites ∙ Books ∙ Papers ∙ Videos ∙ APL Quote Quad ∙ Vector journal ∙ Terminology (Chinese, German) ∙ Neural networks ∙ Error trapping with Dyalog APL (in forms) |
Sharing code | Backwards compatibility ∙ APLcart ∙ APLTree ∙ APL-Cation ∙ Dfns workspace ∙ Tatin ∙ Cider |
Implementation | Resources ∙ Open-source ∙ Magic function ∙ Performance ∙ APL hardware |
Developers | Timeline of corporations ∙ APL2000 ∙ Dyalog ∙ IBM ∙ IPSA ∙ STSC |