- Perl 6 Deep Dive
- Andrew Shitov
- 179字
- 2021-07-03 00:05:46
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.
- C++面向?qū)ο蟪绦蛟O(shè)計(第三版)
- 案例式C語言程序設(shè)計
- C語言程序設(shè)計(第2 版)
- C語言程序設(shè)計
- 64位匯編語言的編程藝術(shù)
- Building a Recommendation Engine with Scala
- Bootstrap 4 Cookbook
- Hands-On Neural Network Programming with C#
- Python期貨量化交易實(shí)戰(zhàn)
- 深入解析Java編譯器:源碼剖析與實(shí)例詳解
- Kotlin進(jìn)階實(shí)戰(zhàn)
- Microsoft Exchange Server 2016 PowerShell Cookbook(Fourth Edition)
- PostgreSQL 12 High Availability Cookbook
- Python繪圖指南:分形與數(shù)據(jù)可視化(全彩)
- jMonkeyEngine 3.0 Beginner’s Guide