=head1 TITLE Inline Comments for Perl. =head1 VERSION Maintainer: Glenn Linderman Date: 14 Aug 2000 Last Modified: 14 Sep 2000 Mailing List: perl6-language@perl.org Number: 102 Version: 2 Status: Frozen =head1 ABSTRACT Unlike many programming languages Perl does not currently implement inline comments. This can be confusing/tedious to programmers. This could be solved by adding a syntax to Perl 6 that would allow for inline comments. =head1 DESCRIPTION Comments are important to programmers as a way of documenting their code and for debugging purposes. Perl's comment syntax requires that comments can only be placed at the end of a line, or on a separate line (or lines). Sometimes it is desirable to place a comment (or comments) within a line. Perl currently uses the "#" character as an end-of-line comment introducer (as do many other scripting languages). RFC 5 (multiline comments) suggests as a possible promising syntax an introducer of the form "#<#". I like this one best, of the three paired character possibilities ("<>", "()", "{}") because it is more closely related to the "#<# comment from appearing, this suggestion is not 100% compatible with perl5 syntax. However, such a sequence is relatively unlikely: I've never seen one in any Perl code I've perused. By limiting this construct to less than a single line, it limits the boundaries of confusion: if "#<" is found with the intended meaning of an end-of-line comment introducer followed by a "<" character, the highly probable lack of the sequence ">#" within the same line can be diagnosed with a warning or error identifying exactly the line involved. =head2 Discussion in perl6-language and perl6-language-mlc There was some discussion of in-line comments in the perl6-language and perl6-language-mlc lists. There wasn't a consensus reached. The competing suggestion for in-line comments was to define "qc/comment/" as a syntax that evaporates. I don't like that syntax, because it looks more like code than comment, and doesn't stand out to the eye as a comment when mixed within code: $foo = qw/foo bar/ qc/eat me/; It is not clear whether such syntax would be easily readable within all forms of expressions, without operators, as shown in the above example, vs $foo = qw/foo bar/ ##; =head1 IMPLEMENTATION Should be straightforward in the Perl parser/lexer. =head1 REFERENCES RFC 5: Multiline Comments for Perl. Discussion archives of the perl-language and perl-language-mlc lists