develooper Front page | perl.perl5.porters | Postings from May 2004

Re: undef loses it magicness when assigned to a variable?

Thread Previous | Thread Next
From:
Stas Bekman
Date:
May 27, 2004 00:55
Subject:
Re: undef loses it magicness when assigned to a variable?
Message ID:
40B59EF3.7010208@stason.org
Why the ideas always come a second after hitting the send button. The obvious 
thing I was missing is to check how pp_defined does the thing. I shouldn't 
have been wasting time searching in the docs :)

Stas Bekman wrote:
[...]
> So how do I check in C whether the passed variable (or a random sv) is 
> undef or not if comparing to &PL_sv_undef doesn't work? 

So I've changed:

- ST(0) == &PL_sv_undef
+ (!ST(1) || !SvANY(ST(1))

and voila, it works whether I call:

   foo(undef);

or

   $x = undef;
   foo($x);

> am I missing 
> some obvious RTFM section? I've read: 'perlguts:=head2 AVs, HVs and 
> undefined values'
> but it doesn't seem to be related. There were many other references to 
> undef in the perl manpages, but I didn't find anything useful.

This should probably be added to the perlguts manpage, next to the
'=head2 AVs, HVs and  undefined values' item.

=head How to check arguments for undefine-ness
...

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

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