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

Re: *foo{SCALAR}

Thread Previous | Thread Next
April 30, 2010 14:25
Re: *foo{SCALAR}
Message ID:
Nicholas Clark wrote:
>I don't see the existing behaviour as a bug. It was quite deliberate.

OK, it's not a bug.  It's still surprising.

>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.

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.


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