like many of you i am fascinated by A5 but also my brain is overwhelmed
by it. i love that /x is the default but i would ask all of you to use
those comments liberally, even with trivial regexes while we all learn
this stuff. even simple ones are tricky looking if you don't grok the
syntax and semantics immediately and i doubt any but larry and damian
do. :)

here is a recent line from damian:

        m/ if  { /<comment>? ::: <keyword>/ and print $0.{comment} } /

i first kept thinking, where is 'if' defined in the regex syntax until
the light hit me and said, that was a literal token! i got the optional
<comment> rule but the ::: is not integrated yet. which form of
commit/backtracking was it? i have learned that $0 is the current regex
object so that last part is prints the comment. but this took a fair
amount of time to figure out as i am still learning this new line
noise. :)

so i would ask that even short perl6 regexes be written with comments
just for education and clarity. later on as it becomes real (code) and
we have a collective understanding and MRE edition 10 is out, we can
relax the comment rules :).

i would write that like (very anal i know):

        m/
            if                          # literal 'if'
            {                           # closure (perl code)
               /                        # internal regex
                   <comment>?           # optional comment rule
                   :::                  # don't backtrack past here ???
                   <keyword>            # followed by keyword rule
               /                        # end of internal regex
               and
               print $0.{comment}       # print comment from internal regex
            }                           # end of closure
         /

now, why does $0.{comment} refer to the internal regex and not the outer
one? is it because of it being in the closure? could you refer to the
outer one from the inner regex?

also since the comment is optional, if you found a keyword wouldn't that
try to print an undefined comment resulting in a warning?

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--- Boston Perl Classes ---- July 1-3 ---- http://stemsystems.com/class/ ----
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to