summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-11-29 11:29:57 +1100
committerNicholas Clark <nick@ccl4.org>2022-02-19 19:46:37 +0000
commitdcab5185619763d819bb4c88c8861b753f428cf4 (patch)
treeb6df1262937fe8f868be00b6e57208f991f3498c
parent123732b0e8f68f17eac6e44a3b027b2ef67c108e (diff)
downloadperl-dcab5185619763d819bb4c88c8861b753f428cf4.tar.gz
document the new flags behaviour and why
-rw-r--r--pod/perlguts.pod24
1 files changed, 24 insertions, 0 deletions
diff --git a/pod/perlguts.pod b/pod/perlguts.pod
index f584a87193..72e544bdba 100644
--- a/pod/perlguts.pod
+++ b/pod/perlguts.pod
@@ -307,6 +307,30 @@ in it, you can use the following macros to check the type of SV you have.
SvNOK(SV*)
SvPOK(SV*)
+Be aware that retrieving the numeric value of an SV can set IOK or NOK
+on that SV, even when the SV started as a string. Prior to Perl
+5.36.0 retrieving the string value of an integer could set POK, but
+this can no longer occur. From 5.36.0 this can be used to distinguish
+the original representation of an SV and is intended to make life
+simpler for serializers:
+
+ /* references handled elsewhere */
+ if (SvIsBOOL(sv)) {
+ /* originally boolean */
+ ...
+ }
+ else if (SvPOK(sv)) {
+ /* originally a string */
+ ...
+ }
+ else if (SvNIOK(sv)) {
+ /* originally numeric */
+ ...
+ }
+ else {
+ /* something special or undef */
+ }
+
You can get and set the current length of the string stored in an SV with
the following macros: