3 Jan 2008 02:58
Re: Multiline comments in Perl6
Jonathan Lang <dataweaver <at> gmail.com>
2008-01-03 01:58:40 GMT
2008-01-03 01:58:40 GMT
I've been putting a fair amount of thought into this. Here's what
I've come up with:
Perl 6 has several instances where whitespace is required or forbidden
in order to better facilitate "Do What I Mean" programming: for
instance, by having the presence or absence of whitespace before curly
braces affect their meaning, you're allowed to omit the parentheses
around the parameters of the various control structures: e.g., 'if $x
{ ... }' is now valid, whereas in Perl 5 you would have had to say 'if
($x) { ... }'. Likewise, the same technique lets you provide an
unambiguous distinction between an infix operator and a postfix
operator (IIRC). So it isn't much of a stretch to require the use of
whitespace in order to distinguish between a standard "line comment"
and an embedded comment.
Except that that isn't what Perl 6 is doing. All that it does is to
say "there's this one case where there's some ambiguity between line
comments and embedded comments; it's up to the programmer to remove
the ambiguity, through whatever means he sees fit." In many ways,
this is the opposite of the above cases, and is more akin to how role
composition must be explicitly disambiguated by the programmer,
instead of having the compiler take a best guess.
I must admit: as nice as it is to be able to create an embedded
comment by wrapping the actual comment in brackets, the existence of
that one point of ambiguity is troubling.
--
What I like about the current embedded comments:
(Continue reading)
RSS Feed