Tweets for 2007-05-15

May 15, 2007

  • Reading the IDC piracy numbers, yarr. #

Powered by Twitter Tools.

Somehow, I managed to resist posting this reply on beginners-perl. Apparently I hate flame wars more than I hate Perl6. Who knew? I still want to put it out there, though:

On 5/14/07, Chas Owens <xxxx.xxxxx@xxxxx.xxx> wrote:

Not that I use them myself, but the “proper” (for various values of
proper) way to use POD for multi-line comments is

=for comment
Commented text
=cut

Yes it sucks, yes it will be fixed* in Perl 6* (or possible earlier if
the trend of adopting Perl 6 features in Perl 5 releases continues).
It will be a quote-like operator, so you will be able to say

 #{
This is
a multi-line comment
}

 #[
so is this
#[ and this one is nested ]
]

#{{{ multiple brackets must match on both sides }}}

* for various definitions of fixed, there are some caveats, the
biggest being that a # as the first character on a line is always
considered a single line comment even if the next character is a
bracketing character. Don’t ask me why.

* http://dev.perl.org/perl6/doc/design/syn/S02.html

Actually, only for a special subset of fixed where 'fixed' eq 'broken'. All I have to say to the Perl6 team on this and a thousand other syntax issues is: “if it ain’t broke, don’t fix it.” We don’t need Perl to be Python or Java. We already have Python and Java, and Ruby besides. We need Perl to be Perl. Perl6, however, is manifestly not Perl, and this is great example of why.

One of the hallmarks of Perl has always been a loose disregard for whitespace. “hash-bracket begins a multi-line comment except at the beginning of a line, or except succeeding a backslash and preceding period, or unless preceded by a space” sounds like the demented ramblings of man trying to write a Java compiler in haskell. Oh, wait… But I digress.

Fortunately, the POD syntax remains fairly sensible. The only change, so far as I know, is a fix to something that was actually broken, namely the =for comment syntax. And what’s more, it’s usable by mere mortals.

=cut

After a good night’s sleep, I’m glad I didn’t hit send. Griping over Perl6 syntax doesn’t belong on the beginner’s list. Of course, I would argue that references to Larry’s Apocalypses don’t, either. Especially no in re FAQs. But that’s a different story.

For those of you playing along at home, the thread started with a question about multi-line comments, and why Perl doesn’t haven an equivalent to C’s ‘/* ... */‘ notation. It’s a common enough question. The simple answer, of course, is POD. For a few corner cases, though, it’s a less-than-optimal solution, so people occasionally clamor for something else. Perl6 is going to give it to them. A hash followed immediately by a bracket of any kind, possibly doubled or tripled, will begin a multi-line comment.

The problem, though, is that the new syntax doesn’t play nice with oh, about a thousand bits and pieces of preprocessors and common utilities. So a hash in column one will remain the beginning of a single-line comment, regardless of what comes after it:

# this is a single-line comment

#{ so is this }

 #{
this is a multi-line comment
}

#{
this is a syntax error
}

Confused? You will be.