September 2017
Beginner
402 pages
9h 52m
English
Embedded comments in Perl 6 are comments that use the syntax of multi-line comments, but are placed inside the main code. Unlike the one-line comments, embedded comments are not propagated until the end of the line and may be terminated by the closing character.
Let's demonstrate an example of an embedded comment on the add function, shown as follows:
sub add($x, $y) {
return $x + #`(this is numeric addition) $y;
}
The #`(this is numeric addition) comment informs the reader that the + operator expects its operands (variables $x and $y in the example) to be numeric values (unlike the concatenation of strings, for example). The whole comment is embedded into the $x + $y expression. After the comment ends, the regular code ...
Read now
Unlock full access