Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: In Defense of Smart::Comments

by {}think (Sexton)
on Jun 23, 2011 at 12:56 UTC ( [id://911077]=note: print w/replies, xml ) Need Help??


in reply to In Defense of Smart::Comments

I'm somewhat enamored of the Smart::Comments module, but have found several shorcomings not mentioned above:

  1. It stops Perl's debugger from performing Run (R) commands for some reason. I have not researched this at all, but have definitely seen that (R) will run your code until the next breakpoint or the next Smart::Comment (sigh).
  2. You can print VARB or LABEL:VARB, but you can't print arbirary strings containing VARBs, such as
                    ### $0 starting
                    ### $var of $var
                    ### $var $var
    
  3. YOU CANNOT have a colon in your Smart comments - the following would cause compile to fail!
                    ## this is record $var: all is well
  4. In-line SMARTCOMMENTS (meaning those to the right of code) do not seem to work. They only work on loops progress bars.
                    $var++;  ### $var
                    ### Did you get that? No, you didn't.
    

{}think; #Think outside of the brackets

Replies are listed 'Best First'.
Re^2: In Defense of Smart::Comments
by Xiong (Hermit) on Aug 21, 2011 at 05:24 UTC

    I've been working on the derivative Devel::Comments.

    1. S::C inserts a breakpoint at every smart comment. My thought was Why. Some developers are interactive debugger guys, some are print-statement debugger guys. If you want both, well, Conway hardcoded in these breakpoints. If you file a (feature request) bug against D::C, I'll make breakpoint insertion optional in 2.0.0.

    2. S::C strongly prefers you to use labelled expressions; I agree it's an issue since I think its best feature is that it generates labels for you. But it's going to have a hard time generating labels for expressions.

    Here's what works in your use cases:

    my $var = 'foo'; ### "$0 starting" ### $var of $var: "$var of $var" ### $var $var: "$var $var"

    3. Don't forget that ## is not a valid introducer. You must use at least ###.

    In any case, yes, the colon is special in smart comments, signifying the end of the label. You don't want to put in two of them, either. The monster regexes that do the source filtering do not like this. You'll notice that a user who filed a bug against an unrelated issue also objects to privileged colons: https://rt.cpan.org/Ticket/Display.html?id=69712

    4. There are excellent reasons to forbid trailing smart comments. To be certain a sequence of octothorpes was intended as a smart comment introducer (and not just some literal text inside something else) would require D::C to parse the whole source code. That said, I'd like trailing smart comments, too. Twist my arm.

    As far as the loop progress bars, they are messy and perhaps not of interest to serious developers. If I don't hear strong support, I'm going to drop them in D::C 2.0.0; I may replace them with more abstract loop-tracing.

    Feste: Misprison in the highest degree. Lady, cucullus non facit monachum. That's as much to say as, I wear not motley in my brain....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://911077]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-18 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found