On Wed, 8 Dec 2004 16:07:43 -0700, Luke Palmer <[EMAIL PROTECTED]> wrote:

Ashley Winters writes:
In a one-liner, I'd rather just use:

$datetime ~~ /$year := (\d+) -? $month := (\d+) -? ...../

I'm starting to think that this '$year := ' syntax is an obfuscator. We couldn't refer to that capture with $year even inside a regex, right? We should use $<year> instead. Maybe $<year> := (\d+) would be less obfuscating.. but it's longer :)
(year:= \d+) and [year:= \d+] are somewhat better, IMHO, but I'm not sure if : in := is unambigous here.
but if /<year>/ and /$year:=.../ both capture to $<year>, why not make thoose two more similar? things like <year:\d+> or <year[\d+]> or <year:> [\d+] come to mind. or that (now unused) <<year>> [\d+]


Then go ahead and use that.  If you're going to use subrules, you can
either use the <?subrule> form or just the regular old <subrule> form
and ignore the result.  There's nothing forcing you to pay attention to
those.  The number variables only get incremented when you use
parentheses.  I'd suspect that the return value of a rule only accounts
for parenthecized captures as well.

.."and ignore the result"? hm. what if someone lazy will put $a ~~ /<rule>/ instead of $a ~~ /<?rule>/, would be there any copying overhead after $a = "something else" (to keep $<rule>, which he isn't even going to use).
(Some perl5 programmers use (...) where (?:...) would be sufficient, just because they are too lazy to put extra two characters, and because it's noisier. <?rule> is better than <<rule>> for noncapturing behaviour in that sense, but I could imagine thoose <?ws> everywhere.. um, just moaning.. maybe old, nonswapped behaviour, was better: <ws> to not capture, <<ws>> to capture (I don't think  and  are appropriate.




Reply via email to