Comment: Difference between revisions
Line 35: | Line 35: | ||
2 ⟃ inline comment ⟄ 3 | 2 ⟃ inline comment ⟄ 3 | ||
2 3 | 2 3 | ||
</syntaxhighlight>{{Works in|[[ | </syntaxhighlight>{{Works in|[[APL64]]}} | ||
== Special comments == | == Special comments == |
Revision as of 17:06, 3 March 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.