in reply to Perlish Debugging Style

You've just reinvented Smart::Comments but in a style that looks like lisp/assembly comments to me. It's really confusing to have leading semi-colons because I'm so used to that having meaning in other languages.

use Smart::Comments; use strict; use warnings; use XML::Simple; use if $ENV{DEBUG}, 'Smart::Comments'; my $struct = XMLin('test.xml'); ### $struct; if (defined $struct) { my $result_set = process_data($struct); ### $result_set; send($result_set); } #...

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: Perlish Debugging Style
by Anonymous Monk on Mar 01, 2006 at 22:11 UTC
    I'm confused.

    Why is there both

    use Smart::Comments;
    and

    use if $ENV{DEBUG},'Smart::Comments';

    I thought the "if" module did conditional inclusion of another module; but you've already included "Smart::Comments" at the beginning, haven't you? Or am I missing something clever?(I probably am :-( ).

    --
    Ytrew

      It's a thinko. I saw only one at a time.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re^2: Perlish Debugging Style
by radiantmatrix (Parson) on Mar 02, 2006 at 17:20 UTC

    BrowserUk had a similar comment, so please consider this a response to both your remarks.

    Smart::Comments is cool -- I hadn't seen that before. It does satisfy a similar itch, but not the *same* itch. My interest is not in having debugging code that only runs while I'm in debugging mode (though there are times when I want that, and Smart::Comments will scratch that itch nicely).

    Instead, my interest is solely in being able to add temporary code which will be physically removed from the source -- whether programatically or not -- before it is released to anyone. It's a stylistic question, and that's all. Many people marks such temporary lines of code by outdenting, surrounding them with special comments, using DEBUG: { } style labeled blocks, etc. Whatever works, you should use. The purpose of the Meditation is a style of highlighting this type of code visually that I've found interesting, with the hope that others who think in a similar way will benefit.

    So, when you say "It's really confusing to have leading semi-colons because I'm so used to that having meaning in other languages.", my only real response is: this meditation is not for you then, use whatever works for you. In fact, I was sort of hoping that other people would share their preferred style for such things.

    Just to be painfully clear, since I get the feeling people are reading more into this meditation than intended: this is not a suggestion for a standard, an assumption that this is better than any other method, etc., nor am I suggesting that these lines be left in any code that is shared with other people.

    I hope that clears things up a bit. ;-) But thank you for pointing me at Smart::Comments, as that will be useful to me for conditional debugging code I *do* want left in.

    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet

      Well... then pass your source through a s/^\s*#{3,}.+/mg filter. You get Smart::Comments *and* you get your redacted distribution. I'd just as soon leave the Smart Comments in there though. You can get better bug reports that way.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊