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

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.

主站蜘蛛池模板: 北碚区| 乌拉特前旗| 曲松县| 宁南县| 新昌县| 临江市| 新竹县| 金湖县| 霍林郭勒市| 香港 | 武强县| 庆城县| 绥滨县| 鹤峰县| 泗洪县| 永靖县| 溧水县| 庄河市| 台州市| 鹿邑县| 洞口县| 涟源市| 保定市| 绥化市| 汽车| 青河县| 鲜城| 蛟河市| 金华市| 安化县| 徐州市| 陵川县| 新营市| 安乡县| 石阡县| 鄱阳县| 繁峙县| 门源| 台中市| 酒泉市| 大城县|