diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 1bacc8496..18d07d8f4 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,17 @@ +2003-09-06 Dirk Herrmann + + * eq.c (scm_eqv_p, scm_equal_p): Removed uses of + SCM_SLOPPY_INEXACTP, SCM_SLOPPY_REALP and SCM_SLOPPY_COMPLEXP. + + * eq.c (scm_eqv_p, scm_equal_p): Reordered comparisons from + 0.0==some_expression to some_expression==0.0. The latter is + better readable. The former is preferred by some people, since it + leads to a compiler error when confusing == with =. However, when + using gcc, a warning will be issued if in an if-statement an + assigment appears. Since many Guile developers are using gcc, + such errors will not remain unnoticed anyway. We can therefore + focus on better readability. + 2003-09-04 Dirk Herrmann * tags.h: Added description of Guile's type system. Removed some diff --git a/libguile/eq.c b/libguile/eq.c index 7068eb31e..676df3ed1 100644 --- a/libguile/eq.c +++ b/libguile/eq.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,2000,2001,2003 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -80,15 +80,15 @@ SCM_PRIMITIVE_GENERIC_1 (scm_eqv_p, "eqv?", scm_tc7_rpsubr, if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y)) { /* treat mixes of real and complex types specially */ - if (SCM_SLOPPY_INEXACTP (x)) + if (SCM_INEXACTP (x)) { - if (SCM_SLOPPY_REALP (x)) - return SCM_BOOL (SCM_SLOPPY_COMPLEXP (y) + if (SCM_REALP (x)) + return SCM_BOOL (SCM_COMPLEXP (y) && real_eqv (SCM_REAL_VALUE (x), SCM_COMPLEX_REAL (y)) - && 0.0 == SCM_COMPLEX_IMAG (y)); + && SCM_COMPLEX_IMAG (y) == 0.0); else - return SCM_BOOL (SCM_SLOPPY_REALP (y) + return SCM_BOOL (SCM_REALP (y) && real_eqv (SCM_COMPLEX_REAL (x), SCM_REAL_VALUE (y)) && SCM_COMPLEX_IMAG (x) == 0.0); @@ -98,8 +98,8 @@ SCM_PRIMITIVE_GENERIC_1 (scm_eqv_p, "eqv?", scm_tc7_rpsubr, if (SCM_NUMP (x)) { if (SCM_BIGP (x)) { - return SCM_BOOL (0 == scm_i_bigcmp (x, y)); - } else if (SCM_SLOPPY_REALP (x)) { + return SCM_BOOL (scm_i_bigcmp (x, y) == 0); + } else if (SCM_REALP (x)) { return SCM_BOOL (real_eqv (SCM_REAL_VALUE (x), SCM_REAL_VALUE (y))); } else { /* complex */ return SCM_BOOL (real_eqv (SCM_COMPLEX_REAL (x), @@ -149,14 +149,14 @@ SCM_PRIMITIVE_GENERIC_1 (scm_equal_p, "equal?", scm_tc7_rpsubr, if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y)) { /* treat mixes of real and complex types specially */ - if (SCM_SLOPPY_INEXACTP (x)) + if (SCM_INEXACTP (x)) { - if (SCM_SLOPPY_REALP (x)) - return SCM_BOOL (SCM_SLOPPY_COMPLEXP (y) + if (SCM_REALP (x)) + return SCM_BOOL (SCM_COMPLEXP (y) && SCM_REAL_VALUE (x) == SCM_COMPLEX_REAL (y) - && 0.0 == SCM_COMPLEX_IMAG (y)); + && SCM_COMPLEX_IMAG (y) == 0.0); else - return SCM_BOOL (SCM_SLOPPY_REALP (y) + return SCM_BOOL (SCM_REALP (y) && SCM_COMPLEX_REAL (x) == SCM_REAL_VALUE (y) && SCM_COMPLEX_IMAG (x) == 0.0); }