develooper Front page | perl.perl6.language | Postings from August 2006

multi-line comments, C macros, & Pod abuse

Thread Next
Joshua Hoblitt
August 18, 2006 14:57
multi-line comments, C macros, & Pod abuse
Message ID:
It occurred to me that other day that in our "in house" C code we
somewhat frequently use an idiom that's not easily translated into Perl
5.  Our rule is that if your commenting out more then 1 or 2 lines of
code that you wrap it in a CPP if statement.  The logic being that
if you haven't deleted the code then it must have some reason of hanging
around (and you may actually want to use it again someday).  This is most
often the case with specialized debugging code. E.g.

    #if 0

The great thing about this is that the you only have to flip the 0 to 1
to re-enable the code. E.g.

    #if 1
    (magic now happens)...

The best equivalent I've been able to come up with in Perl 5 is:

    =for off


    #=for off
    (magic now happens)...

Except that now this requires all sorts of weird voodoo to keep the Pod 
formatting from breaking.

This thread seems to suggest the situation isn't going to change much if
at all in Perl 6:

I guess the point I'm trying to make here is that multi-line comments
about the code and disabled chunks of code are or should be distinct
functionalities.  One can make the argument that any code you want to
disable in the manner I've described should be factored out into it's
own function, so that just the call to the function can be commented
out.  The hard reality is that it's not always so easy or desirable to
do that.  Is there any hope of getting some equivalent "disabled code
chunk" functionality in the perl6 core?




Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About