Stas Bekman <stas@stason.org> writes: >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); But possibly not for $x = 42; ... $x = undef; foo($x); # SvANY is probably still an SvIV > >> 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 >...Thread Previous | Thread Next