bpt/guile.git
13 years ago`load' is a macro (!) that resolves paths relative to source file dir
Andy Wingo [Sat, 12 Feb 2011 22:50:56 +0000 (23:50 +0100)]
`load' is a macro (!) that resolves paths relative to source file dir

* module/ice-9/boot-9.scm (load-in-vicinity): New helper, loads a file
  relative to a path.
  (load): Turn into a macro that captures the name of the source file
  being expanded, and dispatches to load-in-vicinity.  Referencing
  `load' by bare name returns a closure that embeds the current source
  file name.

13 years agoread-enable 'positions by default
Andy Wingo [Sun, 13 Feb 2011 14:04:08 +0000 (15:04 +0100)]
read-enable 'positions by default

* libguile/read.c (scm_read_opts): Default "positions" to #t.  The
  compiler was already turning it on anyway, and this allows
  primitive-load without --auto-compile to also propagate source
  information through the expander, for better errors and to let macros
  know their source.

* module/language/scheme/spec.scm: No need to enable positions here
  now.

13 years agouse scm_c_make_struct in scm_values
Andy Wingo [Sat, 12 Feb 2011 21:19:28 +0000 (22:19 +0100)]
use scm_c_make_struct in scm_values

* libguile/values.c (scm_values): Micro-optimization.

13 years agoAdd `scm_t_subr' typedef (fix bug #23681).
Ludovic Courtès [Sun, 13 Feb 2011 13:50:05 +0000 (14:50 +0100)]
Add `scm_t_subr' typedef (fix bug #23681).

* libguile/__scm.h (scm_t_subr): New typedef.

* libguile/deprecated.h (scm_make_gsubr, scm_make_gsubr_with_generic,
  scm_call_catching_errors): Use it.

* libguile/gsubr.h (scm_c_make_gsubr, scm_c_define_gsubr,
  scm_c_define_gsubr_with_generic): Likewise.

* libguile/smob.h (scm_smob_descriptor)[apply]: Likewise.
  (scm_set_smob_apply): Likewise.

* libguile/snarf.h (SCM_FUNC_CAST_ARBITRARY_ARGS): Likewise.

13 years agoChange `scm_ramapc' prototype to avoid empty declarators (bug #23681).
Ludovic Courtès [Sun, 13 Feb 2011 13:47:33 +0000 (14:47 +0100)]
Change `scm_ramapc' prototype to avoid empty declarators (bug #23681).

* libguile/array-map.h (scm_ramapc): Change `cproc' to `void *' instead
  of using empty declarators.

* libguile/array-map.c (scm_ramapc): Adjust accordingly.

13 years agoFix prototype of `scm_the_vm'.
Ludovic Courtès [Sun, 13 Feb 2011 13:45:47 +0000 (14:45 +0100)]
Fix prototype of `scm_the_vm'.

* libguile/vm.h (scm_the_vm): Use `(void)' instead of `()'.

13 years agofix syntax-error printing
Andy Wingo [Sat, 12 Feb 2011 15:38:02 +0000 (16:38 +0100)]
fix syntax-error printing

* module/ice-9/boot-9.scm: Fix to make "extra" a rest arg.

13 years agofix scm-error invocation on SIGINT in top-repl.scm
Andy Wingo [Sat, 12 Feb 2011 14:58:21 +0000 (15:58 +0100)]
fix scm-error invocation on SIGINT in top-repl.scm

* module/ice-9/top-repl.scm (call-with-sigint): Pass '() as the format
  args when invoking scm-error, to ensure that the error is printable.

13 years agoFixes and improvements to number-theoretic division operators
Mark H Weaver [Thu, 10 Feb 2011 20:40:57 +0000 (15:40 -0500)]
Fixes and improvements to number-theoretic division operators

* libguile/numbers.c (scm_euclidean_quotient, scm_euclidean_divide,
  scm_centered_quotient, scm_centered_divide): Fix bug in inum/inum
  case, where (quotient most-negative-fixnum -1) would not be converted
  to a bignum.

  (scm_euclidean_quotient): Be more anal-retentive about calling
  scm_remember_upto_here_1 after mpz_sgn, (even though mpz_sgn is
  documented as being implemented as a macro and certainly won't
  do any allocation).  It's better to be safe than sorry here.

  (scm_euclidean_quotient, scm_centered_quotient): In the bignum/inum
  case, check if the divisor is 1, since this will allow us to avoid
  allocating a new bignum.

  (scm_euclidean_divide, scm_centered_quotient, scm_centered_divide):
  When computing the intermediate truncated quotient (xx / yy) and
  remainder, use (xx % yy) instead of (xx - qq * yy), on the theory that
  the compiler is more likely to handle this case intelligently and
  maybe combine the operations.

  (scm_euclidean_divide): In the bignum/inum case, we know that the
  remainder will fit in an fixnum, so don't bother allocating a bignum
  for it.

  (scm_euclidean_quotient, scm_euclidean_remainder,
  scm_euclidean_divide, scm_centered_quotient, scm_centered_remainder,
  scm_centered_divide): Minor stylistic changes.

* test-suite/tests/numbers.test: Rework testing framework for
  number-theoretic division operators to be more efficient and
  comprehensive in its testing of code paths and problem cases.

13 years agoAdd comment about handling of exactness specifiers
Mark H Weaver [Thu, 10 Feb 2011 19:35:02 +0000 (14:35 -0500)]
Add comment about handling of exactness specifiers

* libguile/numbers.c: Add discussion on the handling of exactness
  specifiers to the comment above the string-to-number conversion
  functions.

13 years agoFix extensibility of 1-argument atan
Mark H Weaver [Thu, 10 Feb 2011 19:24:39 +0000 (14:24 -0500)]
Fix extensibility of 1-argument atan

* libguile/numbers.c (scm_atan): Call SCM_WTA_DISPATCH_1 instead of
  SCM_WTA_DISPATCH_2 if the second argument is unbound.  Arguably,
  SCM_WTA_DISPATCH_* should handle that case gracefully, but currently
  it doesn't.

13 years agoFix mistake in comment in tags.h
Mark H Weaver [Thu, 10 Feb 2011 19:15:52 +0000 (14:15 -0500)]
Fix mistake in comment in tags.h

* libguile/tags.h: Fix comment in discussion of data representation.
  tc3-code #0b110 indicates a small integer and #0b100 indicates a
  non-integer immediate.  Previously, these were reversed.

13 years agoBump copyright date in REPL version string
Mark H Weaver [Thu, 10 Feb 2011 19:12:12 +0000 (14:12 -0500)]
Bump copyright date in REPL version string

* module/system/repl/common.scm (*version*): Add 2011 to copyright
  date range.

13 years agoMake sure we don't override the user's extension search path.
Ludovic Courtès [Sat, 12 Feb 2011 11:25:18 +0000 (12:25 +0100)]
Make sure we don't override the user's extension search path.

* libguile/dynl.c (augment_env): New function.
  (sysdep_dynl_init): Use it instead of `lt_dladdsearchdir'.

* configure.ac: Define `SHARED_LIBRARY_PATH_VARIABLE'.

13 years agoSave config.cache before tests which are likely to fail.
Ralf Wildenhues [Sat, 12 Feb 2011 09:56:20 +0000 (10:56 +0100)]
Save config.cache before tests which are likely to fail.

Guile's configure script takes fairly long.  On a system without
automatic build dependency installation, it is amplified by the fact
that your user might be both impatient and not read the build
instructions, thus needs to rerun configure several times only to find
out there is another dependency to install.  Still, there is help even
for such kinds of misguided figures such as me: save the temporary
config.cache file (if one is used anyway) before embarking upon the set
of tests that are likely to error out.  That way, the second and further
reruns are much faster.

The downside of this patch is that, when fixing the errors requires
changing to precious variables (such as CPPFLAGS or so), the user will
need to 'rm -f config.cache' to keep configure happy.

* configure.ac: Call AC_CACHE_SAVE before the gmp tests.

13 years agoinstall r6rs exception printer
Andreas Rottmann [Fri, 11 Feb 2011 15:07:14 +0000 (16:07 +0100)]
install r6rs exception printer

* module/rnrs/exceptions.scm: Install an exception printer for R6RS
  exceptions.

13 years agobetter narrowing in catch-all handlers in throw.c
Andy Wingo [Fri, 11 Feb 2011 14:30:25 +0000 (15:30 +0100)]
better narrowing in catch-all handlers in throw.c

* libguile/throw.c (handler_message): Narrow away the catch-closure and
  throw frames.

13 years agopre-boot lookup of print-exception works
Andy Wingo [Fri, 11 Feb 2011 14:21:58 +0000 (15:21 +0100)]
pre-boot lookup of print-exception works

* libguile/backtrace.c (scm_print_exception): Use scm_module_variable to
  look up print-exception so that it works before boot-9 is loaded.

* libguile/throw.c (CACHE_VAR): Tweak to use scm_from_latin1_symbol.

13 years agoscm_handle_by_message uses scm_print_exception
Andy Wingo [Fri, 11 Feb 2011 14:16:25 +0000 (15:16 +0100)]
scm_handle_by_message uses scm_print_exception

* libguile/throw.c (handler_message, should_print_backtrace): Use
  scm_print_exception.  Add a helper function to determine when to print
  a backtrace; don't do so on read or syntax errors.

13 years agoscm_display_error_message, display-error use print-exception
Andy Wingo [Fri, 11 Feb 2011 14:03:38 +0000 (15:03 +0100)]
scm_display_error_message, display-error use print-exception

* libguile/backtrace.c (scm_display_error_message)
  (scm_i_display_error): Use scm_print_exception.

13 years agoprint-exception gets a c binding
Andy Wingo [Fri, 11 Feb 2011 12:13:26 +0000 (13:13 +0100)]
print-exception gets a c binding

* libguile/backtrace.c (scm_print_exception): Add C binding for
  print-exception, which dispatches to whatever is defined in Scheme.
  (boot_print_exception): Add initial binding, replaced later in
  Scheme.

* module/ice-9/boot-9.scm: Expect there to already be a print-exception
  binding.

13 years agorepl.scm: use print-exception
Andy Wingo [Fri, 11 Feb 2011 11:53:02 +0000 (12:53 +0100)]
repl.scm: use print-exception

* module/system/repl/repl.scm: Remove custom exception printers in favor
  of print-exception.

13 years ago(system repl error-handling) uses print-exception
Andy Wingo [Fri, 11 Feb 2011 11:45:48 +0000 (12:45 +0100)]
(system repl error-handling) uses print-exception

* module/system/repl/error-handling.scm (error-string): Just use
  print-exception instead of rolling our own printer.
  (call-with-error-handling): Simplify.

13 years agoadd set-exception-printer!, print-exception to boot-9
Andy Wingo [Fri, 11 Feb 2011 11:44:33 +0000 (12:44 +0100)]
add set-exception-printer!, print-exception to boot-9

* module/ice-9/boot-9.scm (set-exception-printer!, print-exception):
  Define an extensible exception-printing mechanism.
  Also register printers for all keys thrown by Guile.
  Inspired by a patch by Andreas Rottmann.

13 years agoframe-source available in default environment
Andy Wingo [Fri, 11 Feb 2011 11:43:05 +0000 (12:43 +0100)]
frame-source available in default environment

* libguile/frames.c (scm_frame_source): Don't call out to (system vm
  frames), as this routine is used when printing exceptions.  Make
  available in the default environment (ugh).

* module/system/vm/frame.scm: Remove frame-source definition and
  export.

13 years agodeprecate primitive properties
Andy Wingo [Thu, 10 Feb 2011 22:07:03 +0000 (23:07 +0100)]
deprecate primitive properties

* libguile.h:
* libguile/Makefile.am:
* libguile/deprecated.h:
* libguile/deprecated.c:
* libguile/init.c:
* libguile/properties.c:
* libguile/properties.h: Deprecate the "primitive properties"
  interface.  It was only used to implement object properties, and that
  is no longer the case.

* module/ice-9/boot-9.scm (make-object-property): Reimplement just in
  terms of weak hash tables, and make threadsafe.

* NEWS:
* doc/ref/api-utility.texi: Update.

13 years agoports.c safely accesses the port weak hash table
Andy Wingo [Thu, 10 Feb 2011 21:28:19 +0000 (22:28 +0100)]
ports.c safely accesses the port weak hash table

* libguile/ports.h (scm_i_remove_port): Remove declaration, as it was
  SCM_INTERNAL.
* libguile/ports.c (scm_add_to_port_table): Issue a deprecation
  warning if this function is called.  Remove needless SCM_API
  declaration, it was already declared as such in ports.h.  Safely
  access the port table.
  (scm_i_remove_port): Remove bogus comment about lack of need for
  threadsafety.  Take the port table mutex.
  (scm_close_port): No need to take port table mutex around calling
  scm_i_remove_port.

13 years agopre-deprecate scm_ptobs
Andy Wingo [Thu, 10 Feb 2011 20:56:46 +0000 (21:56 +0100)]
pre-deprecate scm_ptobs

* libguile/ports.h (scm_t_ptob_descriptor): Add comment about impending
  ptob deprecation.

13 years agofix potential concurrency bugs in port-for-each
Andy Wingo [Thu, 10 Feb 2011 20:40:25 +0000 (21:40 +0100)]
fix potential concurrency bugs in port-for-each

* libguile/ports.c (scm_c_port_for_each): Simplify to avoid concurrency-
  and gc-related bugs.

13 years agocomment on scm_pre_modules_obarray re threadsafety
Andy Wingo [Thu, 10 Feb 2011 20:19:33 +0000 (21:19 +0100)]
comment on scm_pre_modules_obarray re threadsafety

* libguile/modules.c (scm_pre_modules_obarray): Add comment to the
  effect that this global variable does not need a lock around it.

13 years agoinstructions.c: threadsafe static var
Andy Wingo [Thu, 10 Feb 2011 20:11:47 +0000 (21:11 +0100)]
instructions.c: threadsafe static var

* libguile/instructions.c (fetch_instruction_table): Lock access to the
  static, lazily-generated table.

13 years agomake static hash table access thread-safe in foreign.c
Andy Wingo [Thu, 10 Feb 2011 20:06:55 +0000 (21:06 +0100)]
make static hash table access thread-safe in foreign.c

* libguile/foreign.c (register_weak_reference): Wrap static hash table
  access in a mutex.

13 years agofix potential deadlock in issue-deprecation-warning
Andy Wingo [Thu, 10 Feb 2011 20:06:14 +0000 (21:06 +0100)]
fix potential deadlock in issue-deprecation-warning

* libguile/deprecation.c (scm_c_issue_deprecation_warning): Avoid
  printing to a Scheme port while in a mutex.

13 years ago"latin1" -> "Latin-1".
Ludovic Courtès [Thu, 10 Feb 2011 21:56:37 +0000 (22:56 +0100)]
"latin1" -> "Latin-1".

Reported by Ralf Wildenhues.

* doc/ref/vm.texi (Loading Instructions): Use "Latin-1", not "latin1".

13 years agoAdd `scm_i_set_default_port_encoding' and `scm_i_default_port_encoding'.
Ludovic Courtès [Thu, 10 Feb 2011 21:50:51 +0000 (22:50 +0100)]
Add `scm_i_set_default_port_encoding' and `scm_i_default_port_encoding'.

* libguile/ports.c (scm_i_set_default_port_encoding,
  scm_i_default_port_encoding): New function.  Replace
  `scm_i_set_port_encoding_x' and `scm_i_get_port_encoding' with
  PORT == SCM_BOOL_F.
  (scm_i_set_port_encoding_x): Assume PORT is a port.
  (scm_i_get_port_encoding): Remove.
  (scm_port_encoding): Adjust accordingly.
  (scm_new_port_table_entry): Use `scm_i_default_port_encoding'.

* libguile/ports.h (scm_i_get_port_encoding): Remove declarations.
  (scm_i_default_port_encoding, scm_i_set_default_port_encoding): New
  declarations.

* libguile/posix.c (setlocale): Use `scm_i_set_default_port_encoding'.

13 years agoSimplify `scm_i_set_port_encoding_x'.
Ludovic Courtès [Thu, 10 Feb 2011 21:27:37 +0000 (22:27 +0100)]
Simplify `scm_i_set_port_encoding_x'.

* libguile/ports.c (find_valid_encoding): Remove.
  (scm_i_set_port_encoding_x): Remove call to `find_valid_encoding'.
  Remove `valid_enc'.  Rename `enc' to `encoding'.

* test-suite/tests/ports.test ("port-encoding"): New test prefix.

13 years agoAdd `read-delimited' tests.
Ludovic Courtès [Thu, 10 Feb 2011 22:01:34 +0000 (23:01 +0100)]
Add `read-delimited' tests.

* test-suite/tests/rdelim.test ("read-delimited", "read-delimited!"):
  New test prefixes.

13 years agogetopt-long: arg parsing errors cause print and exit, not backtrace
Andy Wingo [Thu, 10 Feb 2011 11:09:18 +0000 (12:09 +0100)]
getopt-long: arg parsing errors cause print and exit, not backtrace

* module/ice-9/getopt-long.scm (fatal-error): New helper.  For errors
  that come from the user -- i.e., not the grammar -- we will handle our
  own error printing and call `exit' rather than relying on the root
  catch handler.  This is more friendly to the user than a Scheme
  backtrace.
  (parse-option-spec, process-options, getopt-long): Call `fatal-error'
  as appropriate.

* test-suite/tests/getopt-long.test (pass-if-fatal-exception): New
  helper, checks that a certain key was thrown to, and that suitable
  output has been printed on an error port.
  (deferr): Change to expect a 'quit key instead of 'misc-error.  Update
  exceptions to not match the beginning of the string, as that will be
  the program name.  Update tests to use pass-if-fatal-exception.

13 years agogetopt-long cleanups
Andy Wingo [Thu, 10 Feb 2011 10:40:24 +0000 (11:40 +0100)]
getopt-long cleanups

* module/ice-9/getopt-long.scm (process-options): Use `match' in the
  loop.  Clean up `eat' to not take the option being processed.

13 years agogetopt-long cleanup
Andy Wingo [Thu, 10 Feb 2011 10:31:30 +0000 (11:31 +0100)]
getopt-long cleanup

* module/ice-9/getopt-long.scm (process-options): Use more internal
  definitions instead of let-bound functions to decrease the nesting
  depth.

13 years agogetopt-long cleanup
Andy Wingo [Thu, 10 Feb 2011 10:25:22 +0000 (11:25 +0100)]
getopt-long cleanup

* module/ice-9/getopt-long.scm (looks-like-an-option): Remove obtuse use
  of "some".

13 years agogetopt-long uses match:substring from (ice-9 regex)
Andy Wingo [Thu, 10 Feb 2011 10:22:17 +0000 (11:22 +0100)]
getopt-long uses match:substring from (ice-9 regex)

* module/ice-9/getopt-long.scm: Import (ice-9 regex), and use its
  match:substring instead of our own.

13 years agomatch-lambda in getopt-long
Andy Wingo [Thu, 10 Feb 2011 10:19:02 +0000 (11:19 +0100)]
match-lambda in getopt-long

* module/ice-9/getopt-long.scm (parse-option-spec): Use match-lambda to
  parse the grammar.

13 years agogetopt-long uses srfi-9 records internally
Andy Wingo [Thu, 10 Feb 2011 10:04:31 +0000 (11:04 +0100)]
getopt-long uses srfi-9 records internally

* module/ice-9/getopt-long.scm: #:keywords in the define-module block.
  (option-spec): Define as a srfi-9 record instead of playing macro
  games with boot-9 records.

13 years agovolatile locals in bootstrap evaluator
Andy Wingo [Thu, 10 Feb 2011 09:40:57 +0000 (10:40 +0100)]
volatile locals in bootstrap evaluator

* libguile/eval.c (eval): For SCM_M_PROMPT, mark the locals needed after
  a longjmp as volatile.  Perhaps related to bug 32340.

13 years agomore robust fallback error printer
Andy Wingo [Wed, 9 Feb 2011 22:34:36 +0000 (23:34 +0100)]
more robust fallback error printer

* libguile/throw.c (pre_init_throw): Deal with errors printing the
  exception.

13 years agodocs: add missing parentheses in asin formula.
Ralf Wildenhues [Tue, 8 Feb 2011 20:13:07 +0000 (21:13 +0100)]
docs: add missing parentheses in asin formula.

* doc/r5rs/r5rs.texi (Numerical operations): Add parentheses
around argument to sqrt.

13 years agodocs: fix markup in api-options.texi.
Ralf Wildenhues [Tue, 8 Feb 2011 19:52:02 +0000 (20:52 +0100)]
docs: fix markup in api-options.texi.

* doc/ref/api-options.texi (Build Config): Use @env for GUILE_LOAD_PATH.

13 years agofix typos in the manual bits generated from source comments.
Ralf Wildenhues [Sun, 6 Feb 2011 23:29:51 +0000 (00:29 +0100)]
fix typos in the manual bits generated from source comments.

* libguile/bitvectors.c, libguile/chars.c,
libguile/deprecated.c, libguile/numbers.c, libguile/random.c,
libguile/read.c, libguile/root.c, libguile/srfi-1.c,
libguile/srfi-13.c, libguile/srfi-14.c, libguile/uniform.c:
Fix typos, add missing newlines.

13 years agodocs: fix typos in manual, and a couple in code comments.
Ralf Wildenhues [Tue, 8 Feb 2011 20:20:57 +0000 (21:20 +0100)]
docs: fix typos in manual, and a couple in code comments.

* doc/ref/api-binding.texi, doc/ref/api-compound.texi,
doc/ref/api-control.texi, doc/ref/api-debug.texi,
doc/ref/api-io.texi, doc/ref/api-macros.texi,
doc/ref/api-procedures.texi, doc/ref/api-scheduling.texi,
doc/ref/api-undocumented.texi, doc/ref/api-utility.texi,
doc/ref/compiler.texi, doc/ref/goops.texi,
doc/ref/libguile-concepts.texi, doc/ref/misc-modules.texi,
doc/ref/posix.texi, doc/ref/r6rs.texi, doc/ref/slib.texi,
doc/ref/srfi-modules.texi, doc/ref/sxml-match.texi,
doc/ref/tools.texi, doc/ref/vm.texi, doc/ref/web.texi,
doc/sources/env.texi, doc/sources/jimb-org.texi,
doc/sources/scheme-concepts.texi, doc/sources/unix.texi,
module/ice-9/optargs.scm: Fix typos.
* doc/r4rs/r5rs.texi: Likewise.  Do not capitalize code symbols
even at the start of a sentence.
* doc/ref/api-data.texi: Likewise.  Also, remove executable bit.

13 years agoabort on pre-boot throw without catch
Andy Wingo [Wed, 9 Feb 2011 22:15:57 +0000 (23:15 +0100)]
abort on pre-boot throw without catch

* libguile/throw.c (pre_init_throw): Abort instead of exit in the error
  case.  Print out a message.

13 years agofix a couple of (system vm frame) accesses on boot errors
Andy Wingo [Wed, 9 Feb 2011 22:13:53 +0000 (23:13 +0100)]
fix a couple of (system vm frame) accesses on boot errors

* libguile/backtrace.c (display_error_body): Don't look up the
  frame-source if Guile isn't initialized yet.  Fixes display-error
  before boot has finished.

* libguile/throw.c (handler_message): Likewise, don't backtrace before
  boot has finished, because we can't load (system vm frame).

13 years agofix recursive throws if an error occurs at boot-time
Andy Wingo [Wed, 9 Feb 2011 22:01:37 +0000 (23:01 +0100)]
fix recursive throws if an error occurs at boot-time

* libguile/throw.c (find_pre_init_catch): New internal helper.
  (pre_init_throw): If we don't find a catch, print out a message and
  abort.
  (scm_init_throw): Declare pre-init-throw as taking at least one arg.

13 years agoremove dead code in init.c
Andy Wingo [Wed, 9 Feb 2011 22:00:12 +0000 (23:00 +0100)]
remove dead code in init.c

* libguile/init.c: Remove some dead code.

13 years agodocs: remove non-ASCII space from docs.
Ralf Wildenhues [Tue, 8 Feb 2011 20:17:02 +0000 (21:17 +0100)]
docs: remove non-ASCII space from docs.

* doc/ref/api-compound.texi (Vector Accessing from C): Replace
0xa0 character with space.

13 years agoreadline uses define-once
Andy Wingo [Wed, 9 Feb 2011 19:54:36 +0000 (20:54 +0100)]
readline uses define-once

* guile-readline/ice-9/readline.scm: Use define-once.

13 years agoadd define-once
Andy Wingo [Wed, 9 Feb 2011 19:54:22 +0000 (20:54 +0100)]
add define-once

* module/ice-9/boot-9.scm (define-once): New syntax.

* doc/ref/api-binding.texi (Top Level):
* NEWS: Add notes about define-once.

13 years agoImprove type checking when invoking foreign functions.
Ludovic Courtès [Tue, 8 Feb 2011 23:08:14 +0000 (00:08 +0100)]
Improve type checking when invoking foreign functions.

* libguile/foreign.c (unpack): Make sure X is a pointer before using
  `SCM_POINTER_VALUE'.

* test-suite/tests/foreign.test ("pointer->procedure"): New test prefix.

13 years agouninstalled-env ordering tweaks to fix readline's file name
Andy Wingo [Tue, 8 Feb 2011 22:44:27 +0000 (23:44 +0100)]
uninstalled-env ordering tweaks to fix readline's file name

* meta/uninstalled-env.in (subdirs_with_ltlibs): Remove "srfi".
  Reorder the load-path and load-compiled-path to put the root dir after
  guile-readline, so that relative canonicalization computes the correct
  path for ice-9/readline.scm.

13 years agomodule-use-interfaces! handles duplicate interfaces
Andy Wingo [Tue, 8 Feb 2011 22:37:54 +0000 (23:37 +0100)]
module-use-interfaces! handles duplicate interfaces

* module/ice-9/boot-9.scm (module-use-interfaces!): Fix to have the same
  interface de-duplication characteristics as module-use!.

13 years agoremove readline-activator.scm
Andy Wingo [Tue, 8 Feb 2011 22:24:36 +0000 (23:24 +0100)]
remove readline-activator.scm

* guile-readline/readline-activator.scm: Remove this file that was
  deprecated in Guile 1.4.

13 years agoMake `(format #f ...)' always Unicode-capable.
Ludovic Courtès [Tue, 8 Feb 2011 22:14:00 +0000 (23:14 +0100)]
Make `(format #f ...)' always Unicode-capable.

* module/ice-9/format.scm (format): When DESTINATION is #f, use a
  Unicode-capable output string port.

* test-suite/tests/format.test ("format basic output")["default to
  Unicode-capable port"]: New test.

13 years agofix scm_procedure on non-structs
Andy Wingo [Tue, 8 Feb 2011 21:57:45 +0000 (22:57 +0100)]
fix scm_procedure on non-structs

* libguile/procs.c (scm_procedure): Fix argument type check.

13 years agoHave `define-wrapped-pointer-type' take a type name.
Ludovic Courtès [Tue, 8 Feb 2011 21:40:55 +0000 (22:40 +0100)]
Have `define-wrapped-pointer-type' take a type name.

* module/system/foreign.scm (define-wrapped-pointer-type): Add a
  `type-name' argument instead of non-hygienically generating one.

* test-suite/tests/foreign.test (foo): Update.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Update
  accordingly.

13 years agofix quasiquote test
Andy Wingo [Tue, 8 Feb 2011 21:43:43 +0000 (22:43 +0100)]
fix quasiquote test

* test-suite/tests/syntax.test ("quasiquote"): Fix unquote-splicing
  extra args test to update for current behavior.

13 years agohackily fix another case where display-exception would be apropos
Andy Wingo [Tue, 8 Feb 2011 21:41:36 +0000 (22:41 +0100)]
hackily fix another case where display-exception would be apropos

* module/system/repl/error-handling.scm (display-syntax-error)
  (error-string): Until we get the exception-printing patch merged in,
  copy display-syntax-error into error-handling so that we avoid
  display-error.  Fixes bug 32365.

13 years agounquote and unquote-splicing can split multiple expressions
Andy Wingo [Tue, 8 Feb 2011 20:38:57 +0000 (21:38 +0100)]
unquote and unquote-splicing can split multiple expressions

* module/ice-9/psyntax.scm (quasiquote): Import new definition from
  upstream psyntax, to allow unquote and unquote-splicing to take
  multiple arguments.
  (unquote, unquote-splicing): Adapt to not require a particular syntax
  form.

* module/ice-9/psyntax-pp.scm: Regenerated.

13 years agoHack around a defect in `define-wrapped-pointer-type'.
Ludovic Courtès [Mon, 7 Feb 2011 22:53:25 +0000 (23:53 +0100)]
Hack around a defect in `define-wrapped-pointer-type'.

* module/system/foreign.scm (define-wrapped-pointer-type): Choose
  TYPE-NAME deterministically.

13 years agoAdd tests for `memq' and `memv'.
Ludovic Courtès [Mon, 7 Feb 2011 21:12:10 +0000 (22:12 +0100)]
Add tests for `memq' and `memv'.

This is a follow-up to a75ea6589642270adf933b85a15d96a74ff59225 ("fix
memq/memv inlining").

* test-suite/tests/list.test ("memq", "memv"): New test prefixes.

13 years agofix memq/memv inlining
Andy Wingo [Mon, 7 Feb 2011 20:58:51 +0000 (21:58 +0100)]
fix memq/memv inlining

* module/language/tree-il/inline.scm (boolean-value): Add a case for
  applications of primitives, and move the memq/memv->bool code here.
  (inline!): We were inlining (memq 'a '(a b c)) => #t, and not the list
  tail, which was an embarrassing bug.  Fixed by moving this code to the
  boolean-value function.  Thanks to Mark Harig for the report.

13 years agohack around bug in port-filename
Andy Wingo [Mon, 7 Feb 2011 20:43:11 +0000 (21:43 +0100)]
hack around bug in port-filename

* module/ice-9/boot-9.scm (define-module): Until the port-filename bug
  is fixed, hack around it.

13 years agoImproved exactness handling for complex number parsing
Mark H Weaver [Thu, 3 Feb 2011 07:08:26 +0000 (02:08 -0500)]
Improved exactness handling for complex number parsing

When parsing non-real complex numbers, apply exactness specifiers on
per-component basis, as is done in PLT Scheme.  For complex numbers
written in rectangular form, exactness specifiers are applied to the
real and imaginary parts before calling scm_make_rectangular.  For
complex numbers written in polar form, exactness specifiers are applied
to the magnitude and angle before calling scm_make_polar.

There are two kinds of exactness specifiers: forced and implicit.  A
forced exactness specifier is a "#e" or "#i" prefix at the beginning of
the entire number, and applies to both components of a complex number.
"#e" causes each component to be made exact, and "#i" causes each
component to be made inexact.  If no forced exactness specifier is
present, then the exactness of each component is determined
independently by the presence or absence of a decimal point or hash mark
within that component.  If a decimal point or hash mark is present, the
component is made inexact, otherwise it is made exact.

After the exactness specifiers have been applied to each component, they
are passed to either scm_make_rectangular or scm_make_polar to produce
the final result.  Note that this will result in a real number if the
imaginary part, magnitude, or angle is an exact 0.

Previously, both forced and implicit exactness specifiers applied to
the number as a whole _after_ calling scm_make_rectangular or
scm_make_polar.

For example, (string->number "#i5.0+0i") now does the equivalent of:

  (make-rectangular (exact->inexact 5.0) (exact->inexact 0))

which yields 5.0+0.0i.  Previously it did the equivalent of:

  (exact->inexact (make-rectangular 5.0 0))

which yielded 5.0.

* libguile/numbers.c (mem2ureal): Receive a forced exactness specifier
  (forced_x), create and maintain our own implicit exactness specifier
  flag local to this component (implicit_x), and apply these exactness
  specifiers within this function.  Previously, we received a pointer to
  an implicit exactness specifier flag from above, and the exactness
  specifiers were applied from within scm_i_string_length.

  (mem2complex): Receive a forced exactness specifier parameter and pass
  it down to mem2ureal.  Previously, we passed down a pointer to an
  implicit exactness specifier flag instead.

  (scm_i_string_to_number): No longer create an implicit exactness
  specifier flag here, and do not apply exactness specifiers here.  All
  we do here now regarding exactness is to parse the "#e" or "#i" prefix
  (if any) and pass this information down to mem2ureal via mem2complex
  in the form of an explicit exactness specifier (forced_x).

  (scm_c_make_polar): If the cosine and sine of the angle are both NaNs
  and the magnitude is zero, return 0.0+0.0i instead of +nan.0+nan.0i.
  This case happens when the angle is not finite.

* test-suite/tests/numbers.test (string->number): Move the test cases
  for non-real complex numbers into a separate table in which the
  expected real and imaginary parts are separate entries.  Add several
  new test cases.

13 years agoFix non-portable usage of `isinf' in `max' and `min'
Mark H Weaver [Thu, 3 Feb 2011 00:32:16 +0000 (19:32 -0500)]
Fix non-portable usage of `isinf' in `max' and `min'

* numbers.c: Add new macros DOUBLE_IS_POSITIVE_INFINITY and
  DOUBLE_IS_NEGATIVE_INFINITY.
  (scm_max, scm_min): Use the new macros to detect particular
  infinities.  Previously we checked the return value of `isinf'
  to determine the sign of the infinity, but that is not portable.

13 years agoBump version number for 1.9.15.
Ludovic Courtès [Wed, 2 Feb 2011 21:12:05 +0000 (22:12 +0100)]
Bump version number for 1.9.15.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.

13 years agoFix `GUILE_THREAD_LOCAL_STORAGE'.
Ludovic Courtès [Wed, 2 Feb 2011 21:03:18 +0000 (22:03 +0100)]
Fix `GUILE_THREAD_LOCAL_STORAGE'.

* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): Fix M4 quotation.

13 years agoEnclose SRFI-13 deprecation handling in `#if SCM_ENABLE_DEPRECATED == 1'.
Ludovic Courtès [Wed, 2 Feb 2011 21:02:09 +0000 (22:02 +0100)]
Enclose SRFI-13 deprecation handling in `#if SCM_ENABLE_DEPRECATED == 1'.

* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Enclose
  deprecated call convention handling in `#if SCM_ENABLE_DEPRECATED == 1'.

13 years agofix srfi-13 test argument orders
Andy Wingo [Wed, 2 Feb 2011 20:55:13 +0000 (21:55 +0100)]
fix srfi-13 test argument orders

* test-suite/tests/srfi-13.test ("string-filter", "string-delete"): Fix
  argument order in tests.

13 years agoSupport non-real complex numbers with inexact zero imaginary part
Mark H Weaver [Wed, 2 Feb 2011 10:29:55 +0000 (05:29 -0500)]
Support non-real complex numbers with inexact zero imaginary part

Add the ability to represent non-real complex numbers whose imaginary
part is an _inexact_ zero (0.0 or -0.0), per R6RS.  Previously, such
numbers were immediately changed into inexact reals.

* libguile/numbers.c: Remove from the list of `General assumptions' in
  numbers.c that objects satisfying SCM_COMPLEXP() have a non-zero
  complex component.  This is no longer true.  Also add a warning
  about another unrelated assumption that is not entirely correct
  (that floor(r) == r implies that mpz_set_d will DTRT; it won't
  if r is infinite).

  (icmplx2str): Always print the imaginary part, even if it is zero.
  Also handle a negative zero imaginary part more gracefully.  It
  now prints 0.0-0.0i, where previously it would print 0.0+-0.0i.

  (mem2ureal): Replace scm_from_double (0.0) with flo0.

  (scm_c_make_rectangular): Always create non-real complex numbers.
  Previously it would create inexact reals if the specified imaginary
  part was zero.

  (scm_make_rectangular): If the imaginary part is an _exact_ 0, return
  the real part unchanged (possibly exact), otherwise return a non-real
  complex number (possibly with an inexact zero imaginary part).
  Previously, it would return an inexact real number whenever the
  imaginary part was any kind of zero.

  (scm_make_polar): If the magnitude is an exact 0, return an exact 0.
  If the angle is an exact 0, return the magnitude unchanged (possibly
  exact).  Otherwise return a non-real complex number (possibly with an
  inexact zero imaginary part).  Previously, it would return a real
  number whenever the imaginary part was any kind of zero.

  (scm_imag_part): Return an exact 0 if applied to a real number.
  Previously it would return an inexact zero if applied to an inexact
  real number.

  (scm_inexact_to_exact): Accept complex numbers with inexact zero
  imaginary part.  In that case, simply use the real part and ignore the
  imaginary part.  Essentially we coerce the inexact zero imaginary part
  to an exact 0.

* test-suite/tests/numbers.test: Add many test cases, and modify
  existing tests as needed to reflect these changes.  Also add a new
  internal predicate: `almost-real-nan?' which tests for a non-real
  complex number with zero imaginary part whose real part is a NaN.

* doc/ref/api-data.texi (Complex Numbers): Update description of complex
  numbers to reflect these changes: non-real complex numbers in Guile
  need not have non-zero imaginary part.  Also, each part of a complex
  number may be any inexact real, not just rationals as was previously
  stated.  Explicitly mention that each part may be an infinity, a NaN,
  or a signed zero.

  (Complex Number Operations): Change the formal parameter names of
  `make-polar' from `x' and `y' to `mag' and `ang'.

* NEWS: Add news entries.

13 years agoImprove handling of signed zeroes
Mark H Weaver [Wed, 2 Feb 2011 08:14:13 +0000 (03:14 -0500)]
Improve handling of signed zeroes

* libguile/numbers.c (scm_abs): (abs -0.0) now returns 0.0.  Previously
  it returned -0.0.  Also move the REALP case above the BIGP case,
  and consider it SCM_LIKELY to be REALP if not INUMP.
  (scm_difference): (- 0 0.0) now returns -0.0.  Previously it returned
  0.0.  Also make sure that (- 0 0.0+0.0i) will return -0.0-0.0i.

* test-suite/tests/numbers.test (abs, -): Add test cases, and change
  some tests to use `eqv?' instead of `=', in order to test exactness
  and distinguish signed zeroes.

13 years agoTrigonometric functions return exact numbers in some cases
Mark H Weaver [Tue, 1 Feb 2011 11:56:02 +0000 (06:56 -0500)]
Trigonometric functions return exact numbers in some cases

* libguile/numbers.c (scm_sin, scm_cos, scm_tan, scm_asin, scm_acos,
  scm_atan, scm_sinh, scm_cosh, scm_tanh, scm_sys_asinh, scm_sys_acosh,
  scm_sys_atanh): Return an exact result in some cases.

* test-suite/tests/numbers.test: Add test cases.

* NEWS: Add NEWS entry

13 years agoFix `min' and `max' handling of NaNs, infinities, and signed zeroes
Mark H Weaver [Wed, 2 Feb 2011 06:02:49 +0000 (01:02 -0500)]
Fix `min' and `max' handling of NaNs, infinities, and signed zeroes

* libguile/numbers.c (scm_min, scm_max): Properly order the real
  infinities and NaNs, per R6RS, and also take care to handle signed
  zeroes properly.  Note that this ordering is different than that of
  `<', `>', `<=', and `>=', which return #f if any argument is a real
  NaN, and consider the real zeroes to be equal.  The relevant real
  infinity (-inf.0 for min, +inf.0 for max) beats everything, including
  NaNs, and NaNs beat everything else.  Previously these were handled
  improperly in some cases, e.g.:
  (min 1/2 +nan.0) now returns +nan.0 (previously returned 0.5),
  (max 1/2 +nan.0) now returns +nan.0 (previously returned 0.5),
  (min -inf.0 +nan.0) now returns -inf.0 (previously returned +nan.0),
  (max +inf.0 +nan.0) now returns +inf.0 (previously returned +nan.0),
  (min -0.0  0.0) now returns -0.0 (previously returned  0.0),
  (max  0.0 -0.0) now returns  0.0 (previously returned -0.0),
  (max  0   -0.0) now returns  0.0 (previously returned -0.0),
  (max -0.0  0  ) now returns  0.0 (previously returned -0.0).

* test-suite/tests/numbers.test (min, max): Add many more test cases
  relating to NaNs, infinities, and signed zeroes.  Change most existing
  test cases to use `eqv?' instead of `=', in order to check exactness.

13 years agomacro documentation fixup
Noah Lavine [Wed, 2 Feb 2011 14:52:10 +0000 (09:52 -0500)]
macro documentation fixup

* doc/ref/api-macros.texi: make the difference between pattern variables
  and lexical variables a bit clearer.

13 years agoDisable use of thread-local storage on FreeBSD.
Ludovic Courtès [Wed, 2 Feb 2011 17:55:29 +0000 (18:55 +0100)]
Disable use of thread-local storage on FreeBSD.

* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): Explicitly require
  `AC_CANONICAL_HOST'.  Disable on FreeBSD.

13 years agoUpdate `NEWS'.
Ludovic Courtès [Wed, 2 Feb 2011 17:42:19 +0000 (18:42 +0100)]
Update `NEWS'.

* NEWS: Update.

13 years agoR6RS: Have `put-char', `put-string', etc. raise an `&i/o-encoding-error'.
Ludovic Courtès [Wed, 2 Feb 2011 17:00:49 +0000 (18:00 +0100)]
R6RS: Have `put-char', `put-string', etc. raise an `&i/o-encoding-error'.

* module/rnrs/io/ports.scm (&i/o-encoding): New error condition type.
  (with-i/o-encoding-error): New macro.
  (put-char, put-datum, put-string): Use it.

* test-suite/tests/r6rs-ports.test ("8.2.6  Input and output
  ports")["transcoded-port, output [error handling mode = raise]"]: New
  test.

13 years agoChange `scm_encoding_error' to pass the port and faulty character.
Ludovic Courtès [Wed, 2 Feb 2011 16:38:03 +0000 (17:38 +0100)]
Change `scm_encoding_error' to pass the port and faulty character.

* libguile/strings.c (scm_encoding_error): Remove the `from', `to', and
  `string_or_bv' parameters; add `port' and `chr'.
  (scm_to_stringn): Update accordingly.

* libguile/strings.h (scm_encoding_error): Update accordingly.

* libguile/ports.c (scm_ungetc): Update accordingly.

* libguile/print.c (iprin1, scm_write_char): Update accordingly.

* test-suite/tests/encoding-escapes.test ("display output
  errors")["ultima", "Rashomon"]: Check the arguments of
  `encoding-error'.
  ["tekniko"]: New test.

* test-suite/tests/ports.test ("string ports")["wrong encoding"]: Adjust
  to new `encoding-error' arguments.

13 years agoUpon port encoding error, always write as much as possible.
Ludovic Courtès [Wed, 2 Feb 2011 16:33:12 +0000 (17:33 +0100)]
Upon port encoding error, always write as much as possible.

* libguile/print.c (display_string): Upon error, always write the
  OUTPUT_LEN bytes of output, regardless of the conversion strategy.

13 years agoR6RS: Have `get-char', `get-line', etc. raise an `&i/o-decoding-error'.
Ludovic Courtès [Wed, 2 Feb 2011 15:19:48 +0000 (16:19 +0100)]
R6RS: Have `get-char', `get-line', etc. raise an `&i/o-decoding-error'.

* module/rnrs/io/ports.scm (&i/o-decoding): New error condition type.
  (with-i/o-decoding-error): New macro.
  (get-char, get-datum, get-line, get-string-all, lookahead-char): Use
  it.

* test-suite/tests/r6rs-ports.test ("8.2.6  Input and output
  ports")["transcoded-port [error handling mode = raise]"]: Use `guard'
  and `i/o-decoding-error?'.

13 years agoAvoid circular dependency between (rnrs base) and (rnrs exceptions).
Ludovic Courtès [Wed, 2 Feb 2011 15:17:48 +0000 (16:17 +0100)]
Avoid circular dependency between (rnrs base) and (rnrs exceptions).

* module/rnrs/base.scm (raise): Define as a macro instead of a
  procedure.

13 years agoHave `read-char' & co. throw to `decoding-error'.
Ludovic Courtès [Wed, 2 Feb 2011 14:52:56 +0000 (15:52 +0100)]
Have `read-char' & co. throw to `decoding-error'.

* libguile/ports.c (scm_read_char): Mention `decoding-error' in the
  docstring.
  (get_codepoint): Change to return an error code; add `codepoint'
  output parameter.  Don't raise an error from here.
  (scm_getc): Raise an error with `scm_decoding_error' if
  `get_codepoint' returns an error.
  (scm_peek_char): Likewise.  Update docstring.

* libguile/strings.c (scm_decoding_error_key): New variable.
  (scm_decoding_error): New function.
  (scm_from_stringn): Use `scm_decoding_error' instead of
  `scm_encoding_error'.

* libguile/strings.h (scm_decoding_error): New declaration.

* test-suite/tests/ports.test ("string ports")["read-char, wrong
  encoding, error"]: Change to expect `decoding-error'.  Make sure PORT
  points past the error.
  ["read-char, wrong encoding, escape"]: Likewise.
  ["peek-char, wrong encoding, error"]: New test.

* test-suite/tests/r6rs-ports.test ("7.2.11 Binary
  Output")["put-bytevector with wrong-encoding string port"]: Change to
  expect `decoding-error'.
  ("8.2.6  Input and output ports")["transcoded-port [error handling
  mode = raise]"]: Likewise.

* test-suite/tests/rdelim.test ("read-line")["decoding error", "decoding
  error, substitute"]: New tests.

* doc/ref/api-io.texi (Reading): Update documentation of `read-char' and
  `peek-char'.
  (Line/Delimited): Update documentation of `read-line'.

13 years agoUse `#ifdef HAVE_...', not `#if'.
Ludovic Courtès [Wed, 2 Feb 2011 14:13:07 +0000 (15:13 +0100)]
Use `#ifdef HAVE_...', not `#if'.

* test-suite/standalone/test-round.c (test_scm_c_round): Use `#ifdef
  HAVE_FESETROUND', not `#if'.

13 years agoFix typo.
Ludovic Courtès [Wed, 2 Feb 2011 14:12:26 +0000 (15:12 +0100)]
Fix typo.

* libguile/srfi-1.c (scm_srfi1_concatenate_x): Fix `FUNC_NAME'.

13 years agoUse 'substring' instead of obsoleted 'make-shared-substring'
Michael Gran [Wed, 2 Feb 2011 13:45:37 +0000 (05:45 -0800)]
Use 'substring' instead of obsoleted 'make-shared-substring'

* module/system/repl/describe.scm (display-description): replace
  make-shared-substring with substring

13 years agoFix `show' REPL meta-command
Andreas Rottmann [Tue, 1 Feb 2011 22:50:09 +0000 (23:50 +0100)]
Fix `show' REPL meta-command

* module/system/repl/command.scm (warranty, copying, version): Use
  `define-meta-command' to define these procedures, so they are entered
  into the *command-infos* table.

13 years agoImprove discussion of exactness propagation in manual
Mark H Weaver [Thu, 27 Jan 2011 20:57:38 +0000 (15:57 -0500)]
Improve discussion of exactness propagation in manual

* doc/ref/api-data.texi (Exact and Inexact Numbers): Improve the
  discussion of exactness propagation.  Mention that there are
  exceptions to the rule that calculations involving inexact numbers
  must product an inexact result.

13 years agoMove comment about trig functions back where it belongs
Mark H Weaver [Tue, 1 Feb 2011 11:50:48 +0000 (06:50 -0500)]
Move comment about trig functions back where it belongs

* libguile/numbers.c: Move a comment about the trigonometric functions
  next to those functions.  At some point they became separated, when
  scm_expt was placed between them.

13 years agoHandle products with exact 0 differently
Mark H Weaver [Tue, 1 Feb 2011 11:30:29 +0000 (06:30 -0500)]
Handle products with exact 0 differently

* libguile/numbers.c (scm_product): Handle exact 0 differently.  A
  product containing an exact 0 now returns an exact 0 if and only if
  the other arguments are all exact.  An inexact zero is returned if and
  only if the other arguments are all finite but not all exact.  If an
  infinite or NaN value is present, a NaN value is returned.
  Previously, any product containing an exact 0 yielded an exact 0,
  regardless of the other arguments.

  A note on the rationale for (* 0 0.0) returning 0.0 and not exact 0:
  The exactness propagation rules allow us to return an exact result in
  the presence of inexact arguments only if the values of the inexact
  arguments do not affect the result.  In this case, the value of the
  inexact argument _does_ affect the result, because an infinite or NaN
  value causes the result to be a NaN.

  A note on the rationale for (* 0 +inf.0) being a NaN and not exact 0:
  The R6RS requires that (/ 0 0.0) return a NaN value, and that (/ 0.0)
  return +inf.0.  We would like (/ x y) to be the same as (* x (/ y)),
  and in particular, for (/ 0 0.0) to be the same as (* 0 (/ 0.0)),
  which reduces to (* 0 +inf.0).  Therefore (* 0 +inf.0) should return
  a NaN.

* test-suite/tests/numbers.test: Add many multiplication tests.

* NEWS: Add NEWS entry.

13 years agoMore discriminating NaN predicates for numbers.test
Mark H Weaver [Tue, 1 Feb 2011 10:22:40 +0000 (05:22 -0500)]
More discriminating NaN predicates for numbers.test

* test-suite/tests/numbers.test: (real-nan?, complex-nan?,
  imaginary-nan?): Add more discriminating NaN testing predicates
  internal to numbers.test, and convert several uses of `nan?'
  to use these instead:
   * `real-nan?' checks that its argument is real and a NaN.
   * `complex-nan?' checks that both the real and imaginary
                    parts of its argument are NaNs.
   * `imaginary-nan?' checks that its argument's real part
                      is zero and the imaginary part is a NaN.

13 years agoFix bugs in `rationalize'
Mark H Weaver [Tue, 1 Feb 2011 10:19:24 +0000 (05:19 -0500)]
Fix bugs in `rationalize'

* libguile/numbers.c (scm_rationalize): Fix bugs.  Previously, it
  returned exact integers unmodified, although that was incorrect if
  the epsilon was at least 1 or inexact, e.g. (rationalize 4 1) should
  return 3 per R5RS and R6RS, but previously it returned 4.  Also
  handle cases involving infinities and NaNs properly, per R6RS.

* test-suite/tests/numbers.test: Add test cases for `rationalize'.

* NEWS: Add NEWS entry

13 years agoFix and combine NEWS entries on `infinite?' and `finite?'
Mark H Weaver [Tue, 1 Feb 2011 09:40:33 +0000 (04:40 -0500)]
Fix and combine NEWS entries on `infinite?' and `finite?'

* NEWS: Fix and combine NEWS entries on `infinite?' and `finite?'.
  Previous, they stated that these predicates now work on non-real
  complex numbers, but that is not the case.