Front page | perl.perl5.porters |
Postings from June 2011
Re: *foo{SCALAR}
Thread Previous
|
Thread Next
From:
Nicholas Clark
Date:
June 21, 2011 10:48
Subject:
Re: *foo{SCALAR}
Message ID:
20110621174753.GZ23881@plum.flirble.org
On Tue, Jun 21, 2011 at 05:52:45PM +0100, Zefram wrote:
> I'd like to revive this unapplied patch from last year. Summary: package
> scalars currently autovivify very touchily, to the point that *foo{SCALAR}
> is never visibly undef; I think they should autovivify only to the extent
> that package arrays and hashes do. Code on branch zefram/gvsv_empty.
>
> I wrote:
> >As for breakage, note that I only advocate changing the glob deref
> >operator "*foo{SCALAR}", not anything else that looks at GvSV. So this
> >won't break code using arbitrary operators that implicitly reference
> >uninitialised scalars. It'll only break code that explicitly retrieves
> >*foo{SCALAR} and assumes that this is defined. A non-zero amount of
> >code, but small, and updating all that code seems a price worth paying
> >for the added power and consistency.
>
> A couple of people came out in favour of the change, no one objected to
> it, but no one applied the patch. This time round I can apply it myself.
> Anyone object?
This changes very long standing behaviour, and it's not clear whether it
can be subject to any meaningful deprecation warning. That would mean that
it's a flag-day change.
The change makes me nervous - my gut instinct is that this is going to break
a small number of things, but in unexpected ways not covered by tests.
undef autovivies, but autovivifaction in code such as the following doesn't
propagate to its caller:
sub foo {
my $ref = shift;
$$ref = "Pie";
}
which can result in strange subtle runtime breakage without any runtime
warnings, let alone errors.
What on CPAN does it break? [I think I had tried to analyse this last year,
but I don't know if I still have the file any more, as it was on my then-work
desktop, and I don't work there now, and even if I did it's somewhat out of
date]
Nicholas Clark
Thread Previous
|
Thread Next