develooper Front page | perl.perl5.porters | Postings from December 2012

I think b630937 (SvUOK docs) is wrong

Thread Next
From:
Father Chrysostomos
Date:
December 25, 2012 01:07
Subject:
I think b630937 (SvUOK docs) is wrong
Message ID:
20121225010653.4777.qmail@lists-nntp.develooper.com
I think b630937 (SvUOK docs) is wrong

I find this commit questionable:

From b630937b8bf49e835d8976fc1036e68c79585b04 Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Mon, 24 Dec 2012 08:39:58 -0700
Subject: [PATCH] perlapi: Fix misstatement

According to the comments for Perl_sv_setuv(), for performance reasons,
a UV that fits in an IV is stored as an IV.
---
 sv.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sv.h b/sv.h
index b841464..f01a91c 100644
--- a/sv.h
+++ b/sv.h
@@ -655,10 +655,12 @@ Tells an SV that it is an integer and disables all other OK bits.
 Tells an SV that it is an unsigned integer and disables all other OK bits.
 
 =for apidoc Am|bool|SvIOK_UV|SV* sv
-Returns a boolean indicating whether the SV contains an unsigned integer.
+Returns a boolean indicating whether the SV contains an unsigned integer
+that is too large to store as an IV.
 
 =for apidoc Am|bool|SvUOK|SV* sv
-Returns a boolean indicating whether the SV contains an unsigned integer.
+Returns a boolean indicating whether the SV contains an unsigned integer
+that is too large to store as an IV.
 
 =for apidoc Am|bool|SvIOK_notUV|SV* sv
 Returns a boolean indicating whether the SV contains a signed integer.
-- 
1.7.4.1

$ perl -e 'use Devel::Peek; $x = 2147483647; Dump $x; ++$x; Dump $x; --$x; Dump $x'
SV = IV(0x826d8c) at 0x826d90
  REFCNT = 1
  FLAGS = (IOK,pIOK)
  IV = 2147483647
SV = IV(0x826d8c) at 0x826d90
  REFCNT = 1
  FLAGS = (IOK,pIOK,IsUV)
  UV = 2147483648
SV = IV(0x826d8c) at 0x826d90
  REFCNT = 1
  FLAGS = (IOK,pIOK,IsUV)
  UV = 2147483647

That last dump shows a number small enough for an IV, but still
flagged as a UV, so SvUOK will return true.

IMO, the former description was correct.


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