develooper Front page | perl.perl5.porters | Postings from April 2010

Re: *foo{SCALAR}

Thread Previous | Thread Next
Nicholas Clark
April 30, 2010 13:55
Re: *foo{SCALAR}
Message ID:
On Fri, Apr 30, 2010 at 08:04:43PM +0100, Zefram wrote:
> Attached is a pair of patches that address the behaviour of
> *foo{SCALAR}.  As noted in RT #73666, it surprisingly autovivifies.

*foo{SCALAR} existing (and not being undef) has been the behaviour since
(at least) 5.000

> Perhaps more surprisingly, there's an old configuration option for the
> scalar slot to be vivified upon GV creation, which would amount to a
> super-autovivification.  (The option appears to stem from a now-obsolete
> fear that not super-autovivifying might break something.)  So these
> patches remove both sources of autovivification, to reliably give the
> expected semantics.

This changes Perl-space behaviour.

The internal implementation change is not "surprising" - the intent of the
implementation change was to give *no* change from Perl space, whilst changing
the underlying implementation to avoid creating scalars until needed.

I don't see the existing behaviour as a bug. It was quite deliberate.

That doesn't mean that behaviour shouldn't change. But it's a change of
behaviour, not a bug fix. And it will break some existing code.

(Given that when I changed the implementation to what we have now, and
didn't get it "right", so that sometimes *foo{SCALAR} was undef, at least
one module on CPAN did fail tests. One of the YAML modules, IIRC.)

Nicholas Clark

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