summaryrefslogtreecommitdiff
path: root/libguile/eq.c
Commit message (Expand)AuthorAgeFilesLines
* Deprecate dynamic roots...* libguile/root.h: * libguile/root.c: Remove these files. * libguile/deprecated.h: * libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root) (scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate. Remove all root.h usage, which was vestigial. * module/ice-9/serialize.scm: Use (current-thread) instead of (dynamic-root). Andy Wingo2016-11-211-1/+0
* Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: libguile/__scm.h libguile/array-map.c libguile/procprop.c libguile/tags.h module/ice-9/deprecated.scm module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm test-suite/standalone/test-num2integral.c test-suite/tests/regexp.test Andy Wingo2012-01-101-6/+13
|\
| * allocate a tc7 to bitvectors...* libguile/tags.h (scm_tc7_bitvector): Allocate a tc7 to bitvectors. * libguile/print.c (iprin1): * libguile/goops.c: * libguile/evalext.c (scm_self_evaluating_p): * libguile/eq.c (scm_equal_p): Add cases for bitvectors. * libguile/bitvectors.h: Declare internal print and equal? helpers. * libguile/bitvectors.c: Use a tc7 instead of a smob type. Andy Wingo2012-01-091-0/+2
| * allocate a tc7 to arrays...* libguile/tags.h (scm_tc7_array): Allocate a tag for arrays. * libguile/arrays.h (SCM_I_ARRAYP): Change to use scm_tc7_array. The previous definition was not externally usable because scm_i_tc16_array was internal. (scm_i_print_array): Declare, though internally. * libguile/arrays.c (scm_i_make_array): Use scm_cell with the tc7 instead of NEWSMOB. (scm_i_print_array): Make not static. (SCM_ARRAY_IMPLEMENTATION): Adapt. (scm_init_arrays): Remove array smob declaration. * libguile/eq.c (scm_equal_p): Refactor to put the string, pointer, and bytevector cases in the switch. Add a case for arrays. * libguile/goops.c: Add <array> declarations. * libguile/print.c (iprin1): Call scm_i_print_array as needed. * libguile/evalext.c (scm_self_evaluating_p): Add a case for arrays. Andy Wingo2012-01-091-6/+11
* | scm_wta_* procedures replace SCM_WTA_* macros...* libguile/__scm.h: Move all the SCM_WTA and SCM_GASSERT macros out of here. Also remove the scm_call_generic declarations. * libguile/deprecated.h (SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1): (SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_N): Deprecate. See below for their replacements. (SCM_GASSERT0, SCM_GASSERT1, SCM_GASSERT2, SCM_GASSERTn): Deprecate these too. (SCM_WTA_DISPATCH_1_SUBR): Deprecate this strange thing. (scm_call_generic_0, scm_call_generic_1, scm_call_generic_2): (scm_call_generic_3, scm_apply_generic): Remove, indicating their replacements. * libguile/print.c (iprin1): * libguile/eq.c (scm_equal_p): Use scm_call_2 instead of scm_call_generic_2. * libguile/goops.h: * libguile/goops.c: Remove scm_{call,apply}_generic definitions. (scm_wta_dispatch_0, scm_wta_dispatch_1, scm_wta_dispatch_2): (scm_wta_dispatch_n): New procedures, replacing the SCM_WTA macros. * libguile/numbers.c (scm_lcm): * libguile/procs.c (scm_setter): Remove uses of SCM_GASSERT. * libguile/numbers.c (scm_lcm): * libguile/procs.c (scm_setter): * libguile/vectors.c: Use the procedural scm_wta routines instead of the SCM_WTA macros. Andy Wingo2011-05-151-1/+1
|/
* Slight optimization for scm_equal_p...* libguile/eq.c (scm_equal_p): Move SCM_STRUCTP check within the default case of the SCM_TYP7 switch statement, for optimization. Mark H Weaver2011-02-141-8/+8
* `equal?' and `eqv?' are now equivalent for numbers...Change `equal?' to work like `eqv?' for numbers. Previously they worked differently in some cases, e.g. when comparing signed zeroes or NaNs. For example, (equal? 0.0 -0.0) returned #t but (eqv? 0.0 -0.0) returned #f, and (equal? +nan.0 +nan.0) returned #f but (eqv? +nan.0 +nan.0) returned #t. * libguile/numbers.c (scm_real_equalp, scm_bigequal, scm_complex_equalp, scm_i_fraction_equalp): Move to eq.c. * libguile/eq.c (scm_real_equalp): Compare flonums using real_eqv instead of ==, so that NaNs are now considered equal, and to distinguish signed zeroes. (scm_complex_equalp): Compare real and imaginary components using real_eqv instead of ==, so that NaNs are now considered equal, and to distinguish signed zeroes. (scm_bigequal): Use scm_i_bigcmp instead of duplicating it. (real_eqv): Test for NaNs using isnan(x) instead of (x != x), and use SCM_UNLIKELY for optimization. (scm_eqv_p): Use scm_bigequal, scm_real_equalp, scm_complex_equalp, and scm_i_fraction_equalp to compare numbers, instead of inline code. Those predicates now do what scm_eqv_p formerly did internally. Replace if statements with switch statements, as is done in scm_equal_p. Remove useless code to check equality of fractions with different SCM_CELL_TYPEs; this was for a tentative "lazy reduction bit" which was never developed. (scm_eqv_p, scm_equal_p): Remove useless code to check equality between inexact reals and non-real complex numbers with zero imaginary part. Such numbers do not exist, because the current code is careful to never create them. * test-suite/tests/numbers.test: Add test cases for `eqv?' and `equal?'. Change existing test case for `(equal? +nan.0 +nan.0)' to expect #t instead of #f. * NEWS: Add NEWS entries. Mark H Weaver2011-01-301-54/+54
* Define `equal?' for pointer objects....* libguile/eq.c (scm_equal_p): Handle pointer objects. * test-suite/tests/foreign.test ("make-pointer")["equal?", "equal? modulo finalizer", "not equal?"]: New tests. Ludovic Courtès2010-09-231-0/+3
* more fixes to equal? for arrays...* libguile/array-map.c (array_compare, scm_array_equal_p): Rewrite as something that operates on the generic array handle infrastructure. Based on array->list. (scm_i_array_equal_p): Change the docs, as array-equal? is now the same as equal?, except that it typechecks its args. * doc/ref/api-compound.texi (Array Procedures): Update array-equal? docs. * libguile/deprecated.h: * libguile/deprecated.c (scm_raequal): Deprecate. * libguile/bytevectors.c (scm_bytevector_eq_p): Bugfix: bytevectors are bytevector=? only if their element type is the same. * libguile/eq.c (scm_equal_p): Only dispatch to scm_array_equal_p if both args are arrays (generically). * test-suite/tests/arrays.test ("equal?"): Add some more tests. Andy Wingo2010-04-011-1/+1
* Revert "fix equal? between an array and a non-array"...This reverts commit 9d031d4d575ac8f343a5d984cb02cd374577c5a9. Andy Wingo2010-03-301-1/+1
* fix equal? between an array and a non-array...* libguile/eq.c (scm_equal_p): Only call scm_array_equal_p if both arguments are generalized arrays; otherwise they are not equal. Thanks to Daniel Llorens del Río for the tip. * test-suite/Makefile.am: * test-suite/tests/arrays.test: Add a test. Andy Wingo2010-03-301-1/+1
* provide missing prototypes...* libguile/array-map.c: * libguile/chars.c: * libguile/eq.c: * libguile/strorder.c: Provide declarations missing after the asubrs/rpsubrs -> gsubr conversion. Andy Wingo2010-01-071-2/+4
* fluids are tc7 objects...If you're wondering what I'm doing, I'm trying to eventually reimplement smobs in terms of structs, so that applicable smobs can just follow the applicable struct dispatch path. But to do that I have to get structs initialized before things that use smobs, which means transforming a bunch of smobby things to tc7 things. But this transformation is good for performance anyway, and we currently have a glut of unused tc7s, so here we go... * libguile/tags.h (scm_tc7_fluid, scm_tc7_dynamic_state): Fluids (and dynamic states) now have tc7s. * libguile/fluids.h: Remove scm_fluids_prehistory, and add internal scm_i_fluid_print. Update a comment. * libguile/fluids.c: Update for tc7 representation. Also remove the next pointers while we're at it, as they aren't used in the new BDW GC. * libguile/eq.c (scm_equal_p): Remove the hashtable case. Hashtables could never be equal? before, I don't see why to add stubs doing the same thing now. * libguile/print.c (iprin1): * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): Add fluid and dynamic_state cases. * libguile/goops.h: Remove scm_class_hashtable; it will be static. * libguile/goops.c: Make <hashtable> static, and add <fluid> and <dynamic-state> classes. * libguile/hashtab.h: * libguile/hashtab.c: Remove scm_i_hashtable_equal_p. * libguile/init.c (scm_i_init_guile): Remove call to fluids_prehistory. Andy Wingo2009-12-051-3/+0
* hash tables have a tc7...* libguile/tags.h (scm_tc7_hashtable): Allocate a tc7 for hashtables. * libguile/hashtab.h: Adjust macros accordingly. (scm_i_hashtable_print, scm_i_hashtable_equal_p): New internal functions. (scm_hashtab_prehistory): Remove, no more need for this. * libguile/hashtab.c (scm_hash_fn_remove_x): Fix a longstanding bug. (make_hash_table): Adapt to the new hash table representation. * libguile/eq.c (scm_equal_p) * libguile/evalext.c (scm_self_evaluating_p) * libguile/print.c (iprin1) * libguile/gc.c (scm_i_tag_name): Add some tc7_hashtab cases. * libguile/init.c: Remove unused environments init functions. Remove call to hashtab_prehistory. * libguile/goops.h (scm_class_hashtable) * libguile/goops.c (scm_class_of, create_standard_classes): Have to make a class for hash tables manually, because they aren't smobs any more. Andy Wingo2009-12-051-0/+4
* remove rpsubrs...* libguile/tags.h: Remove rpsubrs (I chose to interpret the terse name as "recursive predicate subrs"). Just use gsubrs with rest arguments, or do a fold yourself. * libguile/array-map.c (scm_i_array_equal_p): Do the comparison in order, why not. * libguile/chars.c: * libguile/eq.c: * libguile/numbers.c: * libguile/strorder.c: Add 0,2,1 gsubr wrappers for rpsubrs like eq?, <, etc. * libguile/goops.c (scm_class_of) * libguile/procprop.c (scm_i_procedure_arity) * libguile/procs.c (scm_thunk_p) * libguile/vm.c (apply_foreign): Remove rpsubr cases. * test-suite/tests/numbers.test ("=", "<"): Turn a couple xfails into passes. Andy Wingo2009-12-041-46/+98
* eqv? not a generic, equal? dispatches to generic only for objects...* libguile/eq.c (scm_eqv_p): Not a generic any more. Since eqv? is used by e.g. `case', which should be able to compile into dispatch tables, it really doesn't make sense to dispatch out to a generic. (scm_equal_p): So it was always the case that (equal? 'foo "foo") => #f. But (equal? 'foo 'bar) could actually be extended by a generic. This was a bug, if you follow the other logic of the code. Changed so that generic functions can only extend the domain of equal? when operating on goops objects. * oop/goops.scm: No more eqv? generic. * test-suite/tests/goops.test: Remove eqv? tests. Andy Wingo2009-11-261-11/+15
* fold objects.[ch] into goops.[ch]...Remove objects.h #includes as appropriate. Andy Wingo2009-11-151-1/+0
* Use a TC7 tag instead of a SMOB for bytevectors....* libguile/bytevectors.c (scm_tc16_bytevector): Remove. (SCM_BYTEVECTOR_SET_LENGTH, SCM_BYTEVECTOR_SET_CONTENTS, SCM_BYTEVECTOR_SET_INLINE, SCM_BYTEVECTOR_SET_ELEMENT_TYPE, make_bytevector_from_buffer, scm_is_bytevector, scm_bootstrap_bytevectors): Adjust to the SMOB->tc7 change. (scm_i_print_bytevector): New, formerly `print_bytevector ()'. (bytevector_equal_p): Remove. * libguile/bytevectors.h (SCM_BYTEVECTOR_LENGTH, SCM_BYTEVECTOR_CONTENTS, SCM_BYTEVECTOR_P): Adjust to SMOB->tc7 change. (SCM_BYTEVECTOR_FLAGS, SCM_SET_BYTEVECTOR_FLAGS): New macros. (scm_tc16_bytevector): Remove declaration. (scm_i_print_bytevector): New declaration. * libguile/eq.c (scm_equal_p): Handle `scm_tc7_bytevector'. * libguile/evalext.c (scm_self_evaluating_p): Likewise. * libguile/print.c (iprin1): Likewise. * libguile/tags.h (scm_tc7_bytevector): New. (scm_tc7_unused_8): Remove. * libguile/validate.h (SCM_VALIDATE_BYTEVECTOR): Adjust. * test-suite/tests/bytevectors.test ("Datum Syntax")["self-evaluating?"]: New test. Ludovic Courtès2009-08-301-0/+3
* rename unif.[ch] to arrays.[ch]...* libguile/Makefile.am: * libguile/unif.c: * libguile/unif.h: * libguile/arrays.c: * libguile/arrays.h: Rename unif.[ch] to arrays.[ch]. * libguile.h: * libguile/array-handle.c: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/eq.c: * libguile/gc-card.c: * libguile/gc-malloc.c: * libguile/gc-mark.c: * libguile/gc.c: * libguile/init.c: * libguile/inline.h: * libguile/print.c: * libguile/random.c: * libguile/read.c: * libguile/socket.c: * libguile/sort.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/strports.c: * libguile/vectors.c: * libguile/vectors.h: Update includers. Andy Wingo2009-07-191-1/+1
* rename ramap.[ch] to array-map.[ch]...* libguile/array-map.c: * libguile/array-map.h: Rename from ramap.c and ramap.h. * libguile.h: * libguile/Makefile.am: * libguile/eq.c: * libguile/init.c: * libguile/sort.c: * libguile/unif.c: * libguile/vectors.c: All referrers changed. Andy Wingo2009-07-191-2/+2
* Change Guile license to LGPLv3+...(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* ) Neil Jerram2009-06-171-6/+7
* Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès2008-09-131-1/+1
* * backtrace.c, debug.c, debug.h, deprecation.c, eq.c, eval.c...eval.h, gsubr.c, init.c, macros.c, print.c, print.h, read.c, read.h, stacks.c, symbols.c, throw.c: use private-options.h * private-options.h: new file: contain hardcoded option definitions. Han-Wen Nienhuys2007-01-221-0/+3
* Changes from arch/CVS synchronizationLudovic Courtès2006-06-131-0/+11
* * eq.c (scm_equal_p): Use scm_array_equal_p explicitely when one...of the arguments is a array. This allows vectors to be equal to one-dimensional arrays. * tests/unif.test ("vector equal? one-dimensional array"): New. Marius Vollmer2006-05-291-0/+5
* merge from 1.8 branchKevin Ryde2006-04-171-1/+1
* The FSF has a new address.Marius Vollmer2005-05-231-1/+1
* (SCM_BITVEC_REF, SCM_BITVEC_SET, SCM_BITVEC_CLR): Removed....(scm_vector_elements, scm_vector_writable_elements, scm_generalized_vector_get_handle): Moved to vectors.[hc] from unif.[hc]. (SCM_SIMPLE_VECTOR_LOC): Removed. (SCM_VECTOR_MAX_LENGTH, SCM_VECTOR_LENGTH, SCM_VELTS, SCM_WRITABLE_VELTS, SCM_VECTOR_REF, SCM_VECTOR_SET, scm_vector_equal_p): Moved from vectors.[hc] to deprecated.[hc]. (scm_vector_equal_p, scm_i_vector_equal_p): Renamed former to latter. Changed use in eq.c. Marius Vollmer2005-01-071-1/+1
* More of:...(scm_eq_p, scm_eqv_p, scm_equal_p): Update docstrings from recent revision to the reference manual. Kevin Ryde2004-12-101-6/+6
* (scm_eq_p, scm_eqv_p, scm_equal_p): Update docstrings from...recent revision to the reference manual. Kevin Ryde2004-12-091-15/+89
* Do no longer handle scm_tc7_bvect bitvectors.Marius Vollmer2004-11-091-5/+0
* Do no longer handle old-style uniform vectors.Marius Vollmer2004-11-021-6/+1
* * print.c (iprin1): Removed code for scm_tc7_byvect....* objects.c (scm_class_of): Likewise. * gc-mark.c (scm_gc_mark_dependencies): Likewise. * gc-card.c (scm_i_sweep_card): Likewise. * evalext.c (scm_self_evaluating_p): Likewise. * eq.c (scm_equal_p): Likewise. Marius Vollmer2004-10-271-1/+0
* *** empty log message ***Marius Vollmer2004-09-221-1/+1
* (scm_equal_p): Allow smobs with different flags to be equal by testing...for smobs before insisting on equal SCM_CELL_TYPES. Marius Vollmer2004-09-211-10/+11
* (real_eqv): Pretend that all NaNs are equal.Marius Vollmer2004-09-081-1/+1
* (scm_equal_p): Remove real==fraction and fraction==real, they...must be #f according to R5RS. (equal? follows eqv?, and for eqv? an exact and inexact is #f.) Kevin Ryde2004-08-171-19/+1
* * tags.h, deprecated.h (SCM_EQ_P): Deprecated by moving it into...deprecated.h. Replaced all uses with scm_is_eq. Marius Vollmer2004-07-271-3/+3
* * deprecated.h, boolean.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOL,...SCM_NEGATE_BOOL, SCM_BOOLP): Deprecated by moving into "deprecated.h". Replaced all uses with scm_is_false, scm_is_true, scm_from_bool, and scm_is_bool, respectively. Marius Vollmer2004-07-061-13/+13
* * print.c (scm_iprin1): Handle fractions....* objects.h (scm_class_fraction): New. * objects.c (scm_class_fraction): New. (scm_class_of): Handle fractions. * hash.c (scm_hasher): Handle fractions. * numbers.c: New code for handling fraction all over the place. (scm_odd_p, scm_even_p): Handle inexact integers. (scm_rational_p): New function, same as scm_real_p. (scm_round_number, scm_truncate_number, scm_ceiling, scm_floor): New exact functions that replace the inexact 'dsubr' implementations. (scm_numerator, scm_denominator): New. * numbers.h (SCM_NUMP): Recognize fractions. (SCM_FRACTIONP, SCM_SLOPPY_FRACTIONP, SCM_FRACTION_NUMERATOR, SCM_FRACTION_DENOMINATOR, SCM_FRACTION_SET_NUMERATOR, SCM_FRACTION_SET_DENOMINATOR, SCM_FRACTION_REDUCED_BIT, SCM_FRACTION_REDUCED_SET, SCM_FRACTION_REDUCED_CLEAR, SCM_FRACTION_REDUCED): New. (scm_floor, scm_ceiling, scm_truncate_number, scm_round_number): New prototypes. (scm_make_ratio, scm_rationalize, scm_numerator, scm_denominator, scm_rational_p): New prototypes. (scm_i_dbl2num, scm_i_fraction2double, scm_i_fraction_equalp, scm_i_print_fraction): New prototypes. * goops.c (create_standard_classes): Create "<fraction>" class. * gc-mark.c (scm_gc_mark_dependencies): Handle fractions. * gc-card.c (scm_i_sweep_card): Include scm_tc16_fraction as a case in the switch, but do nothing for now. * eval.c (SCM_CEVAL, SCM_APPLY, call_dsubr_1): Convert fractions to doubles when calling 'dsubr' functions. * eq.c (scm_eqv_p, scm_equal_p): Handle fractions. Marius Vollmer2003-11-181-1/+34
* This set of patches introduces a new tc7 code scm_tc7_number for... numbers. Bignums, reals and complex numbers are turned from smobs into subtypes of scm_tc7_number. * tags.h (scm_tc7_number): New. * eq.c (scm_equal_p), eval.c (SCM_CEVAL), evalext.c (scm_self_evaluating_p), gc-card.c (scm_i_sweep_card), gc-mark.c (scm_gc_mark_dependencies), goops.c (create_smob_classes), hash.c (scm_hasher), numbers.c, numbers.h (SCM_NUMP), objects.c (scm_class_of), print.c (scm_iprin1), smob.c (scm_smob_prehistory): Don't handle bignums, reals and complex numbers as subtypes of scm_tc7_smob any more. * numbers.h, tags.h (scm_tc16_big, scm_tc16_real, scm_tc16_complex): Moved definitions from tags.h to numbers.h. Dirk Herrmann2003-09-181-0/+10
* * 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. Dirk Herrmann2003-09-061-13/+13
* * eq.c (scm_equal_p): Use SCM_TYP7 to check if an object is of... type string, not SCM_TYP7S. Dirk Herrmann2003-09-041-1/+1
* * tests/goops.test: Added tests for correctness of class...precedence list in all basic classes and tests for eqv? and equal?. * goops.scm (compute-getters-n-setters): Check for bad init-thunk. (eqv?): Added default method. (equal?): New default method which uses eqv?. * eq.c (scm_eqv_p): Turned into a primitive generic. Mikael Djurfeldt2003-04-171-2/+5
* Changed license terms to the plain LGPL thru-out.Marius Vollmer2003-04-051-36/+12
* * eq.c (s_scm_eqv_p): scm_i_bigcomp -> scm_i_bigcmp.Rob Browning2003-04-041-1/+1
* * eq.c:: fix various preprocessor usages of new public...symbols to expect 0 or 1 values rather than 1 or undefined. i.e. change #ifdef to #if, etc. Rob Browning2003-03-271-1/+1
* * eq.c: #include <config.h> if HAVE_CONFIG_H. Rename usage of...HAVE_ARRAYS to SCM_HAVE_ARRAYS. Replace usage of HAVE_LONG_LONGS with "SCM_SIZEOF_LONG_LONG != 0". Rob Browning2003-03-251-2/+5
* * srfi-1.c (scm_init_srfi_1): Extend root module map and for-each...with the versions in this module using scm_c_extend_primitive_generic. * goops.scm (equal?): Define default method. * goops.c (scm_primitive_generic_generic): Enable primitive generic if not enabled. (scm_sys_goops_loaded): Setup unextended primitive generics. * goops.c, goops.h (scm_c_extend_primitive_generic): New function. * snarf.h (SCM_PRIMITIVE_GENERIC, SCM_PRIMITIVE_GENERIC_1): New snarf macros. * numbers.c (scm_abs): Use SCM_PRIMITIVE_GENERIC. (This is only a testing example. All uses of SCM_GPROC should be converted.) * procprop.c (scm_stand_in_scm_proc): Use scm_assq instead of scm_assoc. * eq.c (scm_equal_p): Turned into a primitive generic. Mikael Djurfeldt2003-03-061-12/+15
* * eq.c: include <string.h>Gary Houston2002-07-101-1/+7