From e45b0d385c55c3f8c3518f49dc0d128f01bf6c4c Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Thu, 20 Sep 2001 08:02:40 +0000 Subject: [PATCH] * num2integral.i.c (NUM2INTEGRAL): Report an error when these routines are passed an inexact. This change in behavior is motivated by concordance with R5RS: It is more common that a primitive doesn't want to accept an inexact for an exact. --- NEWS | 10 +++++++++- libguile/ChangeLog | 7 +++++++ libguile/num2integral.i.c | 17 ++++++++--------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 302d89e40..dde833df1 100644 --- a/NEWS +++ b/NEWS @@ -1185,13 +1185,21 @@ intended to be used in user code. You should avoid dealing with bignums directly, and should deal with numbers in general (which can be bignums). +** Change in behavior: scm_num2long, scm_num2ulong + +The scm_num2[u]long functions don't any longer accept an inexact +argument. This change in behavior is motivated by concordance with +R5RS: It is more common that a primitive doesn't want to accept an +inexact for an exact. + ** New functions: scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num, scm_size2num, scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint, scm_num2ptrdiff, scm_num2size. These are conversion functions between the various ANSI C integral -types and Scheme numbers. +types and Scheme numbers. NOTE: The scm_num2xxx functions don't +accept an inexact argument. ** New number validation macros: SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,INT,UINT}[_DEF] diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 5834c3148..85a2ade8d 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,10 @@ +2001-09-20 Mikael Djurfeldt + + * num2integral.i.c (NUM2INTEGRAL): Report an error when these + routines are passed an inexact. This change in behavior is + motivated by concordance with R5RS: It is more common that a + primitive doesn't want to accept an inexact for an exact. + 2001-09-17 Dirk Herrmann The following patch partially undoes my patch from 2001-06-30, diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index 0e6c4ed9e..fcb4e369d 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -70,15 +70,14 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) return res; } else if (SCM_REALP (num)) - { /* inexact */ - - double u = SCM_REAL_VALUE (num); - ITYPE res = u; - if ((double) res == u) - return res; - else - scm_out_of_range (s_caller, num); - } + /* Temporary special treatment of this case since behavior has changed */ + scm_error (scm_arg_type_key, + s_caller, + (pos == 0) ? "Wrong type (inexact) argument: ~S" + : "Wrong type (inexact) argument in position ~A: ~S", + (pos == 0) ? scm_list_1 (num) + : scm_list_2 (SCM_MAKINUM (pos), num), + SCM_BOOL_F); else scm_wrong_type_arg (s_caller, pos, num); }