develooper Front page | perl.perl5.porters | Postings from June 2011

Re: *foo{SCALAR}

Thread Previous | Thread Next
From:
Zefram
Date:
June 21, 2011 09:52
Subject:
Re: *foo{SCALAR}
Message ID:
20110621165245.GA2584@lake.fysh.org
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:
>I think it should change.  Distinguishing between "variable by this
>name never referenced" and "variable by this name used and has default
>value" seems as useful for scalars as for arrays, hashes, and subs.
>I have a specific use case where the distinction is vitally important:
>Lexical::Import.  It would be generally useful to anything walking the
>package for debugging or other introspective use.
>
>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?

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