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

[perl #36051] LVALUE magic should know how to assign to globs

From:
Father Chrysostomos via RT
Date:
October 26, 2012 06:32
Subject:
[perl #36051] LVALUE magic should know how to assign to globs
Message ID:
rt-3.6.HEAD-11172-1351258339-1379.36051-15-0@perl.org
On Tue May 31 07:20:09 2005, nicholas wrote:
> 
> This is a bug report for perl from nick@ccl4.org,
> generated with the help of perlbug 1.35 running under perl v5.9.3.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> If you pass a hash element as an argument to a subroutine and assign a
>    glob
> to it, you get inconsistent results.
> 
> If the element did not exist:
> 
> $ perl5.9.3 -MDevel::eeek -le 'sub f { $_[0] = *FOO } f($h{foo}); Dump
>    $h{foo}'
> SV = PVNV(0x8167370) at 0x81633b0
>   REFCNT = 1
>   FLAGS = (POK,pPOK)
>   IV = 0
>   NV = 0
>   PV = 0x81620d0 "*main::FOO"\0
>   CUR = 10
>   LEN = 11
> 
> If the element exists before the call:
> 
> $ perl5.9.3 -MDevel::Peek -le 'sub f { $_[0] = *FOO } $h{foo}=1;
>    f($h{foo}); Dump $h{foo}'
> SV = PVGV(0x818c210) at 0x81630a0
>   REFCNT = 1
>   FLAGS = (GMG,SMG,FAKE,MULTI)
>   IV = 1
>   NV = 0
>   MAGIC = 0x81886c0
>     MG_VIRTUAL = &PL_vtbl_glob
>     MG_TYPE = PERL_MAGIC_glob(*)
>     MG_OBJ = 0x81630a0
>   NAME = "FOO"
>   NAMELEN = 3
>   GvSTASH = 0x81630d0   "main"
>   GP = 0x8174880
>     SV = 0x8176270
>     REFCNT = 2
>     IO = 0x0
>     FORM = 0x0
>     AV = 0x0
>     HV = 0x0
>     CV = 0x0
>     CVGEN = 0x0
>     GPFLAGS = 0x0
>     LINE = 1
>     FILE = "-e"
>     FLAGS = 0x2
>     EGV = 0x8176280     "FOO"
> 
> Presumably now that PVLVs are large enough to hold the full PVGV info,
>    the
> LVALUE tie magic should know how to assign out a typeglob.
> 
> Nicholas Clark

I fixed that in 13be902ce some time ago, but that is not the whole story.

The same thing occurs with regexps.  Substitute ${qr||} for *FOO in the
assignments above, and you will see regexps stringify.

I thought perhaps the solution would be to disallow ${qr||} and make
REGEXP an opaque type, but *foo = qr// has to do something, so I think
it has to remain a scalar.

But XPVLV and struct regexp conflict.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org:443/rt3/Ticket/Display.html?id=36051



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