in reply to Re: Unexpected qr// behavior
in thread Unexpected qr// behavior

IIRC, Ilya Z has said that qr// compiling immediately instead of at first use is an implementation detail. According to that view, qr// is a request to define a resuable regex, not to compile one.

And the key part of reusability is having it maintain it's own flags; Regexp::Common would break seriously if the external flags leaked in.

Replies are listed 'Best First'.
Re: Re: Re: Unexpected qr// behavior
by diotalevi (Canon) on Apr 20, 2004 at 17:13 UTC

    I suppose but the implementation has three cases (in order of best to worst case): re-used as a complete regex, not used at all, re-used as a component of a regex. If that's the motivation I would have thought it would be more important to swap the last two cases so that re-using it as a component isn't worse than not using it at all.

    I'm thinking of /o is dead, long live qr//! for the basis of the sort.

    1. That qr// is compiled once and then used
    2. the qr// is compiled once and then not used
    3. the qr// is compiled twice and used once