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

Re: Objects without stashes?

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
July 13, 2012 06:27
Subject:
Re: Objects without stashes?
Message ID:
20120713132716.GN3041@iabyn.com
On Fri, Jul 13, 2012 at 08:06:50AM -0500, Reini Urban wrote:
> I forgot the simple stash logic that every HV with a NAME is a STASH.
> No need for a flag to check.
> 
> On Fri, Jul 13, 2012 at 7:48 AM, Dave Mitchell <davem@iabyn.com> wrote:
> > On Fri, Jul 13, 2012 at 07:28:14AM -0500, Reini Urban wrote:
> >> SVf_OOK is not needed anymore for HVs as HVs now require always the
> >> hv_aux struct.
> >
> > Huh?
> >
> > $ p -MDevel::Peek -e'my %h; Dump \%h; each %h; Dump \%h' 2>&1 | grep FLAGS
> >   FLAGS = (TEMP,ROK)
> >     FLAGS = (PADMY,SHAREKEYS)
> >   FLAGS = (TEMP,ROK)
> >     FLAGS = (PADMY,OOK,SHAREKEYS)
> 
> Yes, each requires that.
> In my experiments all my simple hashes (created in the compiler) without hv_aux
> fail to work since 5.15, even when not using each. hv_store also
> accesses now RITER.

There's a lot you can do with hashes that don't need hv_aux. At the
end of the following code, OOK is still not set:

    my %h;
    $h{a} = 1;
    @h{qw(b c)} = (2,3);
    delete $h{a};
    @a = $h{b};
    @a = @h{qw(b c)};
    $x = exists $h{b};

The main perl-level thing that requires hv_aux is iteration (keys, each
etc); and I rather wonder whether we could avoid creating it for the list
context versions them?

> We should create all our hashes with hv_aux already and forget about
> the OOK checks.

Lets not.

-- 
I've often wanted to drown my troubles, but I can't get my wife to go
swimming.

Thread Previous | Thread Next


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