develooper Front page | perl.perl5.porters | Postings from March 2007

Re: [PATCH] Alter the package qr// gets blessed into via a pragma

Thread Previous
From:
Tels
Date:
March 20, 2007 15:05
Subject:
Re: [PATCH] Alter the package qr// gets blessed into via a pragma
Message ID:
200703202307.04992@bloodgate.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Moin,

On Tuesday 20 March 2007 23:04:28 Tels wrote:
> Moin,
>
> On Tuesday 20 March 2007 20:11:14 Ævar Arnfjörð Bjarmason wrote:
> > All regular expressions constructed with qr// are currently blessed
> > into the "Regexp" package. This can be altered on a per-regexp basis
> > by doing:
> >
> > my $re = bless qr/Ponies/ => "My::Regexp";
> >
> > But there's no way to alter the default.
> >
> > The attached patch allows for specifying what package regular
> > expressions are blessed into by setting a package name in $^H{regobj},
> > this would allow for writing extensions like the attached
> > re::object::Test (which does nothing at the moment except retrieve the
> > regexp struct from the object).
>
> I really don't like the addition of new globals, wouldn't that really
> screw over code that does something like this:
>
> 	my $qr = $qr;

	my $qr = qr//;			# sorry, typo :)

Currently there is no way to say something like:

	$qr = Regexp->new(/foo/);

or?

> 	if (ref($qr) eq 'Regexp'))	# you probably shouldnt do this anyway?
> 	  {
> 	  }
>
> I think this should still work, but I am not sure:
>
> 	if ($qr->isa('Regexp'))
> 	  {
> 	  }
>
> or?
>
> all the best,
>
> tels



- -- 
 Signed on Tue Mar 20 23:06:23 2007 with key 0x93B84C15.
 Get one of my photo posters: http://bloodgate.com/posters
 PGP key on http://bloodgate.com/tels.asc or per email.

 Marketing lesson #1: The synergy of the result driven leverage can
 *never* incentivize a paradigm shift.

  --  Walterk (124748) on 2004-01-16 at /.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iQEVAwUBRgBpGHcLPEOTuEwVAQK9LQf+L1xQ+72bIV9ZUmGFprcO61cj9tTgLQfh
O6u0rtylGFU/st4fR+e54k2TfxdwXceYtqssKduDpE2MlHhxYSqEhtpViJ/VbZoT
U5XsyRETHf8UEPjA0nyfvbPJ/KcwuvMyvZ+njo8B5vwP2LcqLuoZgKAI57Lt3fzL
HxdO4X9aiKVkMqqsGvVXzmUTUroPNgMFUYShSFqiWaMXrwnP9XJK4RpaVrQhmMFk
/KHVJU7jSwxwYY3PEOSZpkMBX+DF8wiRX9iFNydHh2fAwgQPWKs9ohS1llUJc1lz
vY0vhZWwkvrHealfIzrQUfVNMmwJqUy0EZ023mZt//e0gWX3MpdJ1w==
=jzuk
-----END PGP SIGNATURE-----

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About