develooper Front page | perl.perl5.porters | Postings from August 2010

Re: qr stringification: why are xism always present? I'm worried about backward compatibility

Thread Previous | Thread Next
August 2, 2010 03:11
Re: qr stringification: why are xism always present? I'm worried about backward compatibility
Message ID:
On 1 August 2010 19:24, karl williamson <> wrote:
> But anyway, the new stringification would be (?Cd-xism:foo) or
> (?Cdmx-is:foo).  Is there a reason that the Cd needs to be output?  If not,
> why do the 'xism' always have to be output?

A short answer to why the /xism/ part has to be output:

the (?...) fragment should be sufficient /alone/ to /exactly/ specify
how the snippet is to match, otherwise it cannot be safely embedded
into other patterns without the meaning changing.

However, /p does NOT always get output as it cannot be disabled, it
affects the behavior of the match buffers, not the semantics of the
pattern so it need only be present /somewhere/ in the pattern.

demerphq@gemini:~$ perl -le'print qr/foo/p'
demerphq@gemini:~$ perl -le'print qr/foo/pmsix'

Id like to call your attention to a little problem that caused test
failures when I tried changing it when I did the /p stuff:

yorton@mc02ppcapp-03:~$ perl -le'print qr/foo/msix'
yorton@mc02ppcapp-03:~$ perl -le'print qr/foo/'

Notice the order of the flags is mirrored. If you change this it /will/ break.

The /p modifier is always placed at the front. I dont think you want
to follow this with a two letter modifier.

I personally would not like to see:


be turned into


I would want to see:


I have to say, in all the discussion about what modifers to use, this
aspects of choosing two digit modifiers seems like it hasn't been
completely thought through..

With one letter modifers one can use a charclass to determine
validity. With two letter modifiers order becomes important and one
must use more complex validation mechanisms.

Also, the implementation would probably be considerably simpler with
one-letter modfiers.

I think perhaps we might end up regretting introducing two letter
modifiers. Especially as there is prior art for using /U and things
like that elsewhere.

This isnt just a bike-shed argument there /are/ subtle issues involved
here. Using a lot of /(?:...)/ has a measurable effect on the speed of
parsing patterns. If we introduce more complexity into the process we
will make this problem worse.

Im sorry to bring it up tho.


perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About