NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
inline comments have no syntax (Score:1)
> --- ---
:
>/patpat(?#text)/
Would there be something wrong with instead allowing
either
or
or /
Re:inline comments have no syntax (Score:2)
/ x is the default # so this is a comment
and this is not a comment
At least that's what I remember from yesterday. I wish perl.com was up so I could confirm that
Re:inline comments have no syntax (Score:1)
apo5 explicitly (in text, and by examples such as the one quoted in my post above) says that to get an inline (meaning, I don't want to break my regex into two lines) comment you should assert a string.
So, inline comments don't currently have a syntax, and instead, there is explicit advice to assert a string. I'm wondering whether we can either come up with an appropriate syntax, or not explicitly advise folks to use a kludge.
It just feels like there's something amiss
Re:inline comments have no syntax (Score:2)
Go to page 6 [perl.com] and look at the table at the bottom.
The very first example shows an inline comment.
Re:inline comments have no syntax (Score:1)
Given that he defined "inline comment" to mean "I don't want to break my regex into two lines", he's very much correct. And since that's how Larry refers to inline comments, I'm inclined to agree with him on that definition.
In fact, I'll agree with him across the line: A5 is good, I couldn't do better, this is a nit pick, telling people to use a string assertion as an inline comment is a time-bomb.
Personally I don't much care if we have inline comments (even
Re:inline comments have no syntax (Score:2)
Geez, what a weird nitpick though. I agree that telling people to use inline strings is potentially a problem, but why would you insist on single-line regexes?
Do you try to keep all of you other code on one line too?
Re:inline comments have no syntax (Score:1)
> why would you insist on single-line regexes
Personally, I have zero attachment to in-line comments
in regexen. If your regex is short enough to fit on
one line with an inline comment, then it can darn well
fit on one line with a comment at the end of the line.
So, if there is no support for them, I don't mind.
However, perl5 supports them, and rather than saying
that they go away in perl6, the apo currently documents
(and recomends?) the practice of asserting a string.
*That* is my real nit pick. I think that either the final
spec should say "don't inline comments" or it should say
here's the provided syntax for inlining comments (which
would not be the same as asserting a string).
Having thought about why I've never used in-line regex
comments, I think my vote would be to just not support
them and not advertize any kludge for them either. Tell
folks to put their comment on the end of the line, after
the regexg rather than within it.
Does anyone currently use inline comments rather than the
/x modifier? If so, can you speak to whether and when
inline comments are handy?
-matt
Reply to This
Parent
Re:inline comments have no syntax (Score:1)
Re:inline comments have no syntax (Score:1)
Re:inline comments have no syntax (Score:1)
> so that the p52p6 translator will know what
> it's supposed to translate (?#...) to.
Then the translator shoudl probably have a special
check for inlined empty or '0' (zero) comments. I
don't use inline comments myself, but I can imagine
that someone who does use them might start to type
an inline comment and then forget to fill it in if
they got a phone call, or sudden inspiration in a
more troubling bit of code somewhere else.
I have more trouble imagining a (?#0) comment, but
it seems like a good idea t