Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Comment blocks & private methods

by LanX (Saint)
on Dec 12, 2014 at 16:15 UTC ( [id://1110188]=note: print w/replies, xml ) Need Help??


in reply to Re: Comment blocks & private methods
in thread Comment blocks & private methods

> To me the best solution still is source filters

Actually I agree here, cause I can't possibly see a problem in this case, since comments ARE sourcefilters! :)

Sourcefilters arent bad by definition, it depends on the use case, and this one is legit!

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

update

I have to revoke my opinion, source filters can't distiguish between multi line strings and code.

But pod doesn't have this problem:

$string = " bla =for doc a source filter would delete this part from the string =cut bla ";

Replies are listed 'Best First'.
Re^3: Comment blocks & private methods
by Eily (Monsignor) on Dec 12, 2014 at 16:33 UTC

    Except to parse comments correctly you have to parse perl, because knowing where a string (or string-like anything) starts and ends is really complicated (there are so many ways to start a string in perl that can be nested into each other that you have to parse the whole file correctly to be sure wether one part is code or a string), you wouldn't want your parser to change: "You can also use C-like comments: /* */" into "You can also use C-like comments: " or /\/*\*// # yup, good coding style into /\/ # that works just fine.

    I didn't have that point in mind when I wrote my comment though.

    Edit: in the end yes, POD may actually be the best idea. My bad :D

      > I didn't have that point in mind when I wrote my comment though.

      yeah see my update, (coevolution of better ideas! ;)

      > Edit: in the end yes, POD may actually be the best idea. My bad :D

      maybe a good feature request to to make empty =for without FORMAT and surrounding blank lines official for multi-line comments

      print "start - "; =for bla bla =cut print "stop!";

      My perl-parser as well as perldoc ignore those lines. Only emacs' cperl-mode insist on surrounding blank lines.

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

        Well, if there's a change to include multi line comments, you might as well choose something that doesn't look like what its not and introduce specific syntax (although POD comments have the advantage of not breaking backward compatibility), it's not just about the parsers, it's also about people reading the code (when you get used to POD containing useless code, you may ignore perfectly useful documentation embeded in the code). And well, if the feature still isn't included in perl after all those years, it's certainly not because no one ever thought of a solution, it's on purpose (I'm pretty sure I read somewhere that Larry Wall doesn't like them, for some reasons (and there are good reasons)).

        My perl-parser as well as perldoc ignore those lines. Only emacs' cperl-mode insist on surrounding blank lines.
        IIRC, older POD parsers required blank lines around command paragraphs.

        --MidLifeXis

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-23 17:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found