1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 21:10:27 +02:00

* 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.
This commit is contained in:
Mikael Djurfeldt 2001-09-20 08:02:40 +00:00
parent 5a7f98d1ef
commit e45b0d385c
3 changed files with 24 additions and 10 deletions

10
NEWS
View file

@ -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]

View file

@ -1,3 +1,10 @@
2001-09-20 Mikael Djurfeldt <mdj@linnaeus>
* 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 <D.Herrmann@tu-bs.de>
The following patch partially undoes my patch from 2001-06-30,

View file

@ -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);
}