perl6 icon

Perl 6 - indentable, nestable, multi-line-able delimited comment

Posted in Sun, 16 Jul 2006 15:33:00 GMT

Damian Conway just posted a message about Perl 6 comment enhancement on PerlMonks. I especially like the nestable feature.

Perl 6 [...] introduces an indentable, nestable, multi-line-able delimited comment:

#{ comment 
    here 
}
#[ comment 
    here 
]
#( comment here )
#< comment here >
#« comment etc. »

A delimited comment is introduced by a # followed immediately by any kind of opening bracket. It is closed by the corresponding closing bracket.

John Porter asks for an enhancement which I think would be useful:

Would it be too much to ask that it accept any sequence of openingbrackets — e.g.

#<<<
#<{[

because I could easily see myself wanting to comment out blocks of code with unbalanced closing brackets of all four types (or, more to the point, a dynamic selection of closing bracket types). Having an unlimited variety of comment "identifiers" also facilitates arbitrarily nesting comments without artificial restrictions.

Damian replies:

Not to much to ask at all. At least, not as long as you can be satisfied with multiple repetitions of the same delimiter character. From the latest update of Synopsis 2:

  • For all quoting constructs that use user-selected brackets, multiple, adjacent, identical opening brackets must always be matched by an equal number of adjacent closing brackets. Bracket counting naturally applies only to sets of brackets of the same length:

    say #{{
        Comment contains unmatched } and { { { {
        plus a counted {{ ... }} pair.
    }} q<< <<woot>> >>   # says "<<woot>>"

People have editor macros and other workarounds today but this seems much cleaner.

I saw a few other very cool things in Damian and Larry Wall's Perl 6 presentation at YAPC::NA. Just hope Perl 6 comes out sooner rather than later.

del.icio.us:Perl 6 - indentable, nestable, multi-line-able delimited comment digg:Perl 6 - indentable, nestable, multi-line-able delimited comment reddit:Perl 6 - indentable, nestable, multi-line-able delimited comment spurl:Perl 6 - indentable, nestable, multi-line-able delimited comment wists:Perl 6 - indentable, nestable, multi-line-able delimited comment simpy:Perl 6 - indentable, nestable, multi-line-able delimited comment newsvine:Perl 6 - indentable, nestable, multi-line-able delimited comment blinklist:Perl 6 - indentable, nestable, multi-line-able delimited comment furl:Perl 6 - indentable, nestable, multi-line-able delimited comment fark:Perl 6 - indentable, nestable, multi-line-able delimited comment blogmarks:Perl 6 - indentable, nestable, multi-line-able delimited comment Y!:Perl 6 - indentable, nestable, multi-line-able delimited comment smarking:Perl 6 - indentable, nestable, multi-line-able delimited comment magnolia:Perl 6 - indentable, nestable, multi-line-able delimited comment segnalo:Perl 6 - indentable, nestable, multi-line-able delimited comment

no comments

Comments

(leave url/email »)

   Comment Markup Help Preview comment