Comment
APL allows a comment at the end of a line, separating (optional) code on the left from comments on the right using the lamp glyph ⍝
, thus forming a line comment:
2+3 ⍝ An example of addition 5
Alternatives
An alternative way to write a comment is by exploiting that the left function (⊣
) returns ignores its left argument, but then the comment has to be a string:
2+3 ⊣ 'An example of addition' 5
In fact, the right function (⊢
) can similarly be used to insert a leading or inline comment, although this does undo shyness:
'An example of addition' ⊢ 2+3 5 'The result of the assignment is printed' ⊢ res←2+3 5 2+ 'inline comment' ⊢ 3 5
Inline comment extension
APL64 uniquely adds dedicated syntax for inline comments using ⟃
and ⟄
:
2+ ⟃ inline comment ⟄ 3 5 2 ⟃ inline comment ⟄ + 3 5 2 ⟃ inline comment ⟄ 3 2 3
Special comments
In APL*PLUS, ⍝∇
marks a special "public comment" which can be retrieved with a dedicated system function even when the function is locked. This is also used to distinguish internal documentation from other comments.
Other similar patterns, consisting of the lamp glyph followed by another symbol, are occasionally as indicators to various code analysis tools.
Dyalog APL's Simple APL Library Toolkit (SALT) used ⍝∇:require
as an instruction to load another source file before the current one, although this eventually was superceded by a proper :Require
keyword.
APL features [edit] | |
---|---|
Built-ins | Primitives (functions, operators) ∙ Quad name |
Array model | Shape ∙ Rank ∙ Depth ∙ Bound ∙ Index (Indexing) ∙ Axis ∙ Ravel ∙ Ravel order ∙ Element ∙ Scalar ∙ Vector ∙ Matrix ∙ Simple scalar ∙ Simple array ∙ Nested array ∙ Cell ∙ Major cell ∙ Subarray ∙ Empty array ∙ Prototype |
Data types | Number (Boolean, Complex number) ∙ Character (String) ∙ Box ∙ Namespace ∙ Function array |
Concepts and paradigms | Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity element ∙ Complex floor ∙ Array ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ Glyph ∙ Leading axis theory ∙ Major cell search ∙ First-class function |
Errors | LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR ∙ DOMAIN ERROR ∙ LENGTH ERROR ∙ INDEX ERROR ∙ VALUE ERROR ∙ EVOLUTION ERROR |