summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Bekman <stas@stason.org>2004-05-27 04:25:08 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-05-28 06:29:28 +0000
commit9adebda4fef8cbc5965f9327c10fca15b814f305 (patch)
tree5890001db3450e8b95ce0d8e37fbe0215d978f8e
parent0b8342839983807250e9f986d89f01500807f071 (diff)
downloadperl-9adebda4fef8cbc5965f9327c10fca15b814f305.tar.gz
Re: undef loses it magicness when assigned to a variable?
Message-ID: <40B63284.5040203@stason.org> p4raw-id: //depot/perl@22853
-rw-r--r--pod/perlapi.pod3
-rw-r--r--pod/perlguts.pod19
-rw-r--r--sv.h3
3 files changed, 20 insertions, 5 deletions
diff --git a/pod/perlapi.pod b/pod/perlapi.pod
index 27daa64407..d1ae530433 100644
--- a/pod/perlapi.pod
+++ b/pod/perlapi.pod
@@ -3196,7 +3196,8 @@ Found in file sv.h
=item SvOK
-Returns a boolean indicating whether the value is an SV.
+Returns a boolean indicating whether the value is an SV. It also tells
+whether the value is defined or not.
bool SvOK(SV* sv)
diff --git a/pod/perlguts.pod b/pod/perlguts.pod
index 9932b37547..99c79d0a43 100644
--- a/pod/perlguts.pod
+++ b/pod/perlguts.pod
@@ -201,9 +201,22 @@ you can call:
SvOK(SV*)
The scalar C<undef> value is stored in an SV instance called C<PL_sv_undef>.
-Its address can be used whenever an C<SV*> is needed.
-However, you have to be careful when using C<&PL_sv_undef> as a value in AVs
-or HVs (see L<AVs, HVs and undefined values>).
+
+Its address can be used whenever an C<SV*> is needed. Make sure that
+you don't try to compare a random sv with C<&PL_sv_undef>. For example
+when interfacing Perl code, it'll work correctly for:
+
+ foo(undef);
+
+But won't work when called as:
+
+ $x = undef;
+ foo($x);
+
+So to repeat always use SvOK() to check whether an sv is defined.
+
+Also you have to be careful when using C<&PL_sv_undef> as a value in
+AVs or HVs (see L<AVs, HVs and undefined values>).
There are also the two values C<PL_sv_yes> and C<PL_sv_no>, which contain
boolean TRUE and FALSE values, respectively. Like C<PL_sv_undef>, their
diff --git a/sv.h b/sv.h
index fab44ebc91..4edd87fd33 100644
--- a/sv.h
+++ b/sv.h
@@ -410,7 +410,8 @@ double. Checks the B<private> setting. Use C<SvNIOK>.
Unsets the NV/IV status of an SV.
=for apidoc Am|bool|SvOK|SV* sv
-Returns a boolean indicating whether the value is an SV.
+Returns a boolean indicating whether the value is an SV. It also tells
+whether the value is defined or not.
=for apidoc Am|bool|SvIOKp|SV* sv
Returns a boolean indicating whether the SV contains an integer. Checks