develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #108780] overload::StrVal and qr//

Thread Previous | Thread Next
Father Chrysostomos via RT
January 29, 2012 13:03
[perl #108780] overload::StrVal and qr//
Message ID:
On Sun Jan 29 12:32:58 2012, davem wrote:
> On Wed, Jan 25, 2012 at 02:02:14PM -0800, Father Chrysostomos via RT
> > It will conflict with his changes (which will render this redundant,
> > once complete),
> Not necessarily redundant, although different; regexes will still be
> string-concatenated and qr// objects stringified.
> > but that has already happened before.  All he has to do
> > is revert the commit when rebasing (which, too, has already happened
> > before).
> yes, but it makes my life harder: I effectively have to throw your patch
> away, then write a new fix in a different way (grumble grumble).

If I volunteer to write the new fix, do you mind if I apply my fix to
blead now?  I’ll leave the PL_reginterp_cnt hack in sv_2pv for now and
simply repeat it in pp_regcomp.  (Removing the hack from sv_2pv has
enough implications to make my head spin.)

> On Thu, Jan 26, 2012 at 01:44:19PM -0800, Father Chrysostomos via RT
> > The PL_reginterp_cnt hack in sv_2pv_flags seems to have been added for
> > regcomp’s sake to begin with.  So why wasn’t it just added to regcomp? 
> > For overloading?  The commit that added it (2cd61cdbd) mentions no such
> > thing.
> > 
> > My patch moves that hack into regcomp, where it arguably belongs.
> My code will eventually remove PL_reginterp_cnt altogether.
> Just for the record, when I've finished, the way run-time patterns with
> multiple components (i.e. /foo$a.{?{})$b$qr_obj/ etc) will be handled is
> roughly:
>     for (@args) {
> 	do get magic, and apply qr// overloading to each one
>     }
>     my $pat;
>     for (@args) {
> 	if $_ is associated with some code blocks, grab them and add to a list;
> 	if $_ is a REGEXP; extract code blocks from it and add to the list;
> 	$pat .= $_ (with '.' overloading, and fallback to "" overloading)
> 	if we used '.' overload above, discard list of compile-time code blocks;
>     }
>     regex-compile $pat; for each '(?{})' encountered, if there is a
>     corresponding pre-compiled code-block, use that, otherwise treat it as
>     a run-time code block and compile it just there.
> Note that I still expect to stringify and interpolate everything,
> including REGEXP objects; the only difference is that the (?{})'s in them
> may not necessarily be recompiled; instead, previously-compiled
> may be reused, depending on scoping, closures etc. And the concatenating
> now takes place in Perl_re_compile (renamed to Perl_re_op_compile and with
> a different signature, with Perl_re_compile as a back-compat wrapper),
> rather than in pp_regcomp as before.
> Note also that there are three types of overloading involved when
> assembling a pattern string:
>     qr   overloading, which expects an overloaded obj to return a qr//;
>     '.'  overloading, to concatenate two adjacent elements;
>     '""' overloading, for fallback stringification when concatenating.

Is there any chance your incomplete work could be merged to blead?

After all, it’s already better that what we now have in blead.


Father Chrysostomos

via perlbug:  queue: perl5 status: open

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