官术网_书友最值得收藏!

Embedded comments

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 flow continues. The compiler ignores the comment and, thus, the line remains syntactically correct.

Embedded comments should be as short as possible to make the whole code easier to read. Use it to give small explanations or to temporarily disable a fragment of code during the debugging of the program.

主站蜘蛛池模板: 乌兰察布市| 广元市| 鄱阳县| 泰兴市| 怀远县| 武功县| 淮南市| 南岸区| 紫阳县| 宜春市| 石棉县| 武宣县| 墨脱县| 东丽区| 沙雅县| 成安县| 克山县| 沙河市| 惠东县| 龙州县| 灌阳县| 仙游县| 茌平县| 鄱阳县| 永清县| 新丰县| 建德市| 河津市| 祁东县| 常德市| 锦州市| 财经| 信宜市| 丹东市| 自治县| 宣化县| 新兴县| 凤台县| 工布江达县| 孟津县| 德昌县|