Comment: Difference between revisions
(Created page with "{| class=vertical-navbox style="float:right; font-size:500%; margin:0 1ex;" |<code><nowiki>⍝</nowiki></code> |} 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 <syntaxhighlight lang=apl inline>⍝</syntaxhighlight>, thus forming a line comment: <syntaxhighlight lang=apl> 2+3 ⍝ An example of addition 5 </syntaxh...") |
|||
Line 44: | Line 44: | ||
[[Dyalog APL]]'s ''Simple APL Library Toolkit'' (SALT) used <syntaxhighlight lang=apl inline>⍝∇:require</syntaxhighlight> as an instruction to load another source file before the current one, although this eventually was superceded by a proper <syntaxhighlight lang=apl inline>:Require</syntaxhighlight> [[keyword]]. | [[Dyalog APL]]'s ''Simple APL Library Toolkit'' (SALT) used <syntaxhighlight lang=apl inline>⍝∇:require</syntaxhighlight> as an instruction to load another source file before the current one, although this eventually was superceded by a proper <syntaxhighlight lang=apl inline>:Require</syntaxhighlight> [[keyword]]. | ||
{{APL | {{APL syntax}} |
Revision as of 09:49, 14 February 2024
⍝
|
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.