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
    ...
    #endif

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)...
    #endif

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

    =for off
    ...
    =cut

&

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

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:

http://groups.google.com/group/perl.perl6.language/browse_thread/thread/45f5be3ca97d1d82/cd5f1daa256be9b9?lnk=gst&q=multiline+comments&rnum=1#cd5f1daa256be9b9

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?

Cheers,

-J

--

Attachment: pgp86uJCumyZZ.pgp
Description: PGP signature

Reply via email to