bpt/guile.git
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.

13 years agoUpdate copyright date of manual, and a small fix
Mark H Weaver [Tue, 1 Feb 2011 09:31:13 +0000 (04:31 -0500)]
Update copyright date of manual, and a small fix

* doc/ref/guile.texi: Update copyright date to 2011.

* doc/ref/r6rs.texi (rnrs base): Fix typo: `rem0' -> `div0'.

13 years agoupdate NEWS
Andy Wingo [Mon, 31 Jan 2011 22:20:32 +0000 (23:20 +0100)]
update NEWS

* NEWS: Update.

13 years agoImprove extensibility of `expt' and `integer-expt'
Mark H Weaver [Sun, 30 Jan 2011 15:51:36 +0000 (10:51 -0500)]
Improve extensibility of `expt' and `integer-expt'

* libguile/numbers.c (scm_integer_expt): No longer require that the
  first argument be a number, in order to improve extensibility.  This
  allows us to efficiently raise arbitrary objects to an integer power
  as long as we can multiply those objects.  For example, this allows us
  to efficiently exponentiate matrices if we define only multiplication
  methods for matrices.  Note also that scm_expt calls this procedure
  whenever the exponent is an integer, regardless of the type of the
  first argument.  Also rearrange the order in which we test special
  cases.

* test-suite/tests/numbers.test (expt, integer-expt): Comment out tests
  that required `(expt #t 0)' and `(integer-expt #t 0)' to throw
  exceptions.  Add tests for (expt #t 2) and `(integer-expt #t 2)
  instead.

* NEWS: Add NEWS entry

13 years agotoplevel vars added by syntax expansion are unbound
Andy Wingo [Mon, 31 Jan 2011 20:02:24 +0000 (21:02 +0100)]
toplevel vars added by syntax expansion are unbound

* module/ice-9/psyntax.scm (chi-top): When adding to the toplevel
  environment at compile-time, default to undefined variables, not
  variables defined to #f.

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

* module/ice-9/boot-9.scm (module-add!): Add a new pre-modules version
  of this function, so we can add variables the environment, not just
  values.
  (module-define!): Use module-add!.

13 years agoRename {euclidean,centered}_quo_rem to {euclidean,centered}_divide
Mark H Weaver [Mon, 31 Jan 2011 17:03:02 +0000 (12:03 -0500)]
Rename {euclidean,centered}_quo_rem to {euclidean,centered}_divide

* libguile/numbers.c (euclidean_quo_rem): Rename to euclidean_divide.
  (centered_quo_rem): Rename to {euclidean,centered}_divide.

* libguile/numbers.h: Rename euclidean_quo_rem to euclidean_divide and
  centered_quo_rem to centered_divide.

* doc/ref/api-data.texi: Rename euclidean_quo_rem to euclidean_divide and
  centered_quo_rem to centered_divide.

13 years agoDisable stand-alone tests that require `dlopen' when `--disable-shared'.
Ludovic Courtès [Mon, 31 Jan 2011 18:26:01 +0000 (19:26 +0100)]
Disable stand-alone tests that require `dlopen' when `--disable-shared'.

* configure.ac (HAVE_SHARED_LIBRARIES): New Automake conditional.

* test-suite/standalone/Makefile.am (check_SCRIPTS): Add `test-asmobs',
  `test-ffi', and `test-extensions' only when `HAVE_SHARED_LIBRARIES'.

13 years agoRework the testing framework for number-theoretic division operators
Mark H Weaver [Mon, 31 Jan 2011 05:42:35 +0000 (00:42 -0500)]
Rework the testing framework for number-theoretic division operators

* test-suite/tests/numbers.test (test-eqv?): Remove special handling of
  zeroes.  Zeroes are now compared like all other numbers.  Exact
  numbers are compared with `eqv?' and inexact numbers are compared to
  within test-epsilon.

  Rework the testing framework for number-theoretic division operators:
  `euclidean/', `euclidean-quotient', `euclidean-remainder',
  `centered/', `centered-quotient', and `centered-remainder'.
  Previously we compared all test results against a simple scheme
  implementation of the same operations.  However, these operations have
  discontinuous jumps where a tiny change in the inputs can lead to a
  large change in the outputs, e.g.:

    (euclidean/ 130.00000000000 10/7) ==> 91.0 and 0.0
    (euclidean/ 129.99999999999 10/7) ==> 90.0 and 1.42857142856141

  In the new testing scheme, we compare values against the simple
  implementations only if the input arguments contain an infinity or a
  NaN.  In the common case of two finite arguments, we simply make sure
  that the outputs of all three operators (e.g. `euclidean/',
  `euclidean-quotient', `euclidean-remainder') equal each other, that
  outputs are exact iff both inputs are exact, and that the required
  properties of the operator are met: that Q is an integer, that R is
  within the specified range, and that N = Q*D + R.

13 years agoAdd `pointer?'.
Ludovic Courtès [Sun, 30 Jan 2011 21:47:35 +0000 (22:47 +0100)]
Add `pointer?'.

* libguile/foreign.c (scm_pointer_p): New function.
* libguile/foreign.h (scm_pointer_p): New declaration.
* module/system/foreign.scm: Export `pointer?'.

* test-suite/tests/foreign.test ("null pointer")["pointer?"]: New
  test.
  ("make-pointer")["pointer?"]: New test.

* doc/ref/api-foreign.texi (Foreign Variables): Document `pointer?'.

13 years agoRemove the "has finalizer?" bit from pointer objects.
Ludovic Courtès [Sun, 30 Jan 2011 21:05:21 +0000 (22:05 +0100)]
Remove the "has finalizer?" bit from pointer objects.

* libguile/foreign.h (SCM_POINTER_HAS_FINALIZER): Remove.

* libguile/foreign.c (scm_from_pointer): Store nothing more than
  `scm_tc7_pointer' in the type slot.

13 years agoAdd `define-wrapped-pointer-type'.
Ludovic Courtès [Sun, 30 Jan 2011 21:00:35 +0000 (22:00 +0100)]
Add `define-wrapped-pointer-type'.

* module/system/foreign.scm (define-wrapped-pointer-type): New macro.

* doc/ref/api-foreign.texi (Foreign Types): Mention the `*' symbol.
  (Void Pointers and Byte Access): Document `define-wrapped-pointer-type'.

* test-suite/tests/foreign.test ("define-wrapped-pointer-type"): New
  test prefix.

13 years agoImprove extensibility of core numeric procedures
Mark H Weaver [Sun, 30 Jan 2011 14:52:51 +0000 (09:52 -0500)]
Improve extensibility of core numeric procedures

* libguile/numbers.c (scm_quotient, scm_remainder, scm_modulo,
  scm_zero_p, scm_positive_p, scm_negative_p, scm_real_part,
  scm_imag_part, scm_numerator, scm_denominator, scm_magnitude,
  scm_angle, scm_exact_to_inexact): Change from SCM_GPROC to
  SCM_PRIMITIVE_GENERIC.  As a side effect, all of these procedures now
  have documentation strings.

  (scm_exact_p, scm_inexact_p, scm_odd_p, scm_even_p, scm_finite_p,
  scm_inf_p, scm_nan_p, scm_expt, scm_inexact_to_exact, scm_log,
  scm_log10, scm_exp, scm_sqrt): Change from SCM_DEFINE to
  SCM_PRIMITIVE_GENERIC, and make sure the code allows these functions
  to be extended in practice.

  (scm_real_part, scm_imag_part, scm_numerator, scm_denominator,
  scm_inexact_to_exact): Simplify type dispatch code.

  (scm_sqrt): Rename formal argument from x to z, since complex numbers
  are supported.

  (scm_abs): Fix empty FUNC_NAME.

* libguile/numbers.h (scm_finite_p): Add missing prototype.

  (scm_inf_p, scm_nan_p): Rename formal parameter from n to x, since
  the domain is the real numbers.

* test-suite/tests/numbers.test: Test for documentation strings.  Change
  from `expect-fail' to `pass-if' for several of these, and add tests
  for others.  Also add other tests for `real-part' and `imag-part',
  which previously had none.

13 years agoAdd two new sets of fast quotient and remainder operators
Mark H Weaver [Sun, 30 Jan 2011 13:48:28 +0000 (08:48 -0500)]
Add two new sets of fast quotient and remainder operators

* libguile/numbers.c (scm_euclidean_quo_and_rem, scm_euclidean_quotient,
  scm_euclidean_remainder, scm_centered_quo_and_rem,
  scm_centered_quotient, scm_centered_remainder): New extensible
  procedures `euclidean/', `euclidean-quotient', `euclidean-remainder',
  `centered/', `centered-quotient', `centered-remainder'.

* libguile/numbers.h: Add function prototypes.

* module/rnrs/base.scm: Remove incorrect stub implementations of `div',
  `mod', `div-and-mod', `div0', `mod0', and `div0-and-mod0'.  Instead do
  renaming imports of `euclidean-quotient', `euclidean-remainder',
  `euclidean/', `centered-quotient', `centered-remainder', and
  `centered/', which are equivalent to the R6RS operators.

* module/rnrs/arithmetic/fixnums.scm (fxdiv, fxmod, fxdiv-and-mod,
  fxdiv0, fxmod0, fxdiv0-and-mod0): Remove redundant checks for division
  by zero and unnecessary complexity.
  (fx+/carry): Remove unneeded calls to `inexact->exact'.

* module/rnrs/arithmetic/flonums.scm (fldiv, flmod, fldiv-and-mod,
  fldiv0, flmod0, fldiv0-and-mod0): Remove redundant checks for division
  by zero and unnecessary complexity.  Remove unneeded calls to
  `inexact->exact' and `exact->inexact'

* test-suite/tests/numbers.test: (test-eqv?): New internal predicate for
  comparing numerical outputs with expected values.

  Add extensive test code for `euclidean/', `euclidean-quotient',
  `euclidean-remainder', `centered/', `centered-quotient',
  `centered-remainder'.

* test-suite/tests/r6rs-arithmetic-fixnums.test: Fix some broken test
  cases, and remove `unresolved' test markers for `fxdiv', `fxmod',
  `fxdiv-and-mod', `fxdiv0', `fxmod0', and `fxdiv0-and-mod0'.

* test-suite/tests/r6rs-arithmetic-flonums.test: Remove `unresolved'
  test markers for `fldiv', `flmod', `fldiv-and-mod', `fldiv0',
  `flmod0', and `fldiv0-and-mod0'.

* doc/ref/api-data.texi (Arithmetic): Document `euclidean/',
  `euclidean-quotient', `euclidean-remainder', `centered/',
  `centered-quotient', and `centered-remainder'.

  (Operations on Integer Values): Add cross-references to `euclidean/'
  et al, from `quotient', `remainder', and `modulo'.

* doc/ref/r6rs.texi (rnrs base): Improve documentation for `div', `mod',
  `div-and-mod', `div0', `mod0', and `div0-and-mod0'.  Add
  cross-references to `euclidean/' et al.

* NEWS: Add NEWS entry.

13 years agoAdd SCM_LIKELY and SCM_UNLIKELY for optimization
Mark H Weaver [Sat, 29 Jan 2011 04:58:02 +0000 (23:58 -0500)]
Add SCM_LIKELY and SCM_UNLIKELY for optimization

* libguile/numbers.c (scm_abs, scm_quotient, scm_remainder, scm_modulo):
  Add SCM_LIKELY and SCM_UNLIKELY in several places for optimization.

  (scm_remainder): Add comment about C99 "%" semantics.
  Strip away a redundant set of braces.

13 years agoFix GOOPS method compilation bug when no next-method exists
Mark H Weaver [Sun, 30 Jan 2011 03:07:49 +0000 (22:07 -0500)]
Fix GOOPS method compilation bug when no next-method exists

* module/oop/goops/compile.scm (compute-cmethod): Fix a bug
  that caused the method compiler to barf while compiling a
  method that calls (next-method), if there is no applicable
  next method.

13 years agoImplement R6RS `real-valued?', `rational-valued?', `integer-valued?'
Mark H Weaver [Sat, 29 Jan 2011 04:42:01 +0000 (23:42 -0500)]
Implement R6RS `real-valued?', `rational-valued?', `integer-valued?'

* module/rnrs/base.scm (real-valued?, rational-valued?,
  integer-valued?): Implement in compliance with R6RS.

* test-suite/tests/r6rs-base.test: Add test cases for
  `real-valued?', `rational-valued?', and `integer-valued?'.

* NEWS: Add NEWS entries.

13 years agoInfinities and NaNs are no longer rational
Mark H Weaver [Sat, 29 Jan 2011 04:32:20 +0000 (23:32 -0500)]
Infinities and NaNs are no longer rational

* libguile/numbers.c (scm_rational_p): Return #f for infinities and
  NaNs, per R6RS.  Previously it returned #t for real infinities
  and NaNs.  They are still considered real by scm_real `real?'
  however, per R6RS.  Also simplify the code.

  (scm_real_p): New implementation to reflect the fact that the
  rationals and reals are no longer the same set.  Previously it just
  called scm_rational_p.

  (scm_integer_p): Simplify the code.

* test-suite/tests/numbers.test: Add test cases for `rational?'
  and `real?' applied to infinities and NaNs.

* doc/ref/api-data.texi (Real and Rational Numbers): Update docs to
  reflect the fact that infinities and NaNs are no longer rational, and
  that `real?'  no longer implies `rational?'.  Improve discussion of
  infinities and NaNs.

* NEWS: Add NEWS entries, and combine with an earlier entry about
  infinities no longer being integers.

13 years ago`equal?' and `eqv?' are now equivalent for numbers
Mark H Weaver [Sat, 29 Jan 2011 00:57:41 +0000 (19:57 -0500)]
`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.

13 years agoRemove useless test and fix spelling errors
Mark H Weaver [Sat, 29 Jan 2011 00:13:47 +0000 (19:13 -0500)]
Remove useless test and fix spelling errors

* test-suite/tests/numbers.test: Remove test for lazy reduction bit of
  fractions, which was never implemented.  Fix some spelling errors.

13 years agoDon't remove `standard-library.texi' upon "make clean".
Ludovic Courtès [Sat, 29 Jan 2011 22:31:38 +0000 (23:31 +0100)]
Don't remove `standard-library.texi' upon "make clean".

* doc/ref/Makefile.am (CLEANFILES): Rename to...
  (DISTCLEANFILES): ... this.  So that "make clean" doesn't remove
  `standard-library.texi'.  Reported by Hans Åberg <haberg-1@telia.com>.

13 years agoAdd missing include for MinGW.
Ludovic Courtès [Sat, 29 Jan 2011 21:28:48 +0000 (22:28 +0100)]
Add missing include for MinGW.

* libguile/ports.h: Include <unistd.h>.

13 years agoMake `inet-ntop' and `inet-pton' available even when !HAVE_IPV6.
Ludovic Courtès [Sat, 29 Jan 2011 21:26:42 +0000 (22:26 +0100)]
Make `inet-ntop' and `inet-pton' available even when !HAVE_IPV6.

* libguile/socket.c (scm_inet_pton, scm_inet_ntop): Move out of `#ifdef
  HAVE_IPV6' and conditionalize the IPv6-specific bits.  Reported by
  Jan Nieuwenhuizen <janneke@gnu.org>.

13 years agoWhen cross building, run GUILE_FOR_BUILD instead of just-built guile.
Jan Nieuwenhuizen [Sat, 29 Jan 2011 18:51:37 +0000 (19:51 +0100)]
When cross building, run GUILE_FOR_BUILD instead of just-built guile.

* meta/guile.in: Run @GUILE_FOR_BUILD@ when cross-compiling.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoHave `srfi-19.test' use the non-deprecated `format' style.
Ludovic Courtès [Sat, 29 Jan 2011 20:46:44 +0000 (21:46 +0100)]
Have `srfi-19.test' use the non-deprecated `format' style.

* test-suite/tests/srfi-19.test: Fix all uses of `format' to pass a port
  or Boolean as the first argument.

13 years agoAdd a test for `send' and `recv!'.
Ludovic Courtès [Sat, 29 Jan 2011 20:24:04 +0000 (21:24 +0100)]
Add a test for `send' and `recv!'.

* test-suite/tests/socket.test ("AF_UNIX/SOCK_STREAM")["bind (bis)",
  "listen (bis)", "recv!", "accept (bis)"]: New tests.

13 years agoHave `recv!', `send', etc. accept a bytevector.
Ludovic Courtès [Sat, 29 Jan 2011 20:34:44 +0000 (21:34 +0100)]
Have `recv!', `send', etc. accept a bytevector.

* libguile/socket.c (scm_recv, scm_send, scm_recvfrom, scm_sendto):
  Expect the buffer to be a bytevector.  Move the string-handling
  code under `#if SCM_ENABLE_DEPRECATED == 1' and issue a deprecation
  warning.

* test-suite/tests/socket.test ("AF_UNIX/SOCK_DGRAM")["sendto",
  "sendto/sockaddr"]: Adjust accordingly.

* doc/ref/posix.texi (Network Sockets and Communication): Update
  documentation of `recv!', `send', `recvfrom!', and `sendto'.

13 years agoAdd `-lgc' to `Libs' in `guile-2.0.pc'.
Ludovic Courtès [Sat, 29 Jan 2011 15:41:53 +0000 (16:41 +0100)]
Add `-lgc' to `Libs' in `guile-2.0.pc'.

This accounts for the fact that some public Guile macros and inline
functions use libgc functions.

* meta/guile-2.0.pc.in (Libs.private): Move @BDW_GC_LIBS@ to...
  (Libs): ... here.  Reported by Hans Aberg <haberg-1@telia.com>.

* meta/guile-2.0-uninstalled.pc.in: Likewise.

13 years agoupdate api-evaluation.texi
Andy Wingo [Fri, 28 Jan 2011 16:11:56 +0000 (17:11 +0100)]
update api-evaluation.texi

* doc/ref/api-evaluation.texi (Compilation): Update compile-file and
  compiled-file-name docs.

13 years agoFix bugs when negating SCM_MOST_POSITIVE_FIXNUM+1
Mark H Weaver [Wed, 26 Jan 2011 10:21:03 +0000 (05:21 -0500)]
Fix bugs when negating SCM_MOST_POSITIVE_FIXNUM+1

* libguile/numbers.c (scm_difference, scm_product):
  Fix bugs when negating SCM_MOST_POSITIVE_FIXNUM+1,
  aka -SCM_MOST_NEGATIVE_FIXNUM.  Previously, these cases
  failed to normalize the result to a fixnum, causing
  `=', `eqv?' and `equal?' to fail, e.g.:
  (= most-negative-fixnum (- 0 (- most-negative-fixnum)))
  (= most-negative-fixnum (* -1 (- most-negative-fixnum)))
  (= most-negative-fixnum (* (- most-negative-fixnum) -1))

* test-suite/test/numbers.test: Add test cases to detect
  bugs when negating SCM_MOST_POSITIVE_FIXNUM+1 and
  SCM_MOST_NEGATIVE_FIXNUM by various methods.

13 years agonote inf? / nan? domain in NEWS
Mark H Weaver [Fri, 28 Jan 2011 12:51:37 +0000 (13:51 +0100)]
note inf? / nan? domain in NEWS

* NEWS: Add NEWS entry.

13 years agodomain of inf?, finite?, nan? is the real numbers
Andy Wingo [Wed, 26 Jan 2011 09:34:55 +0000 (04:34 -0500)]
domain of inf?, finite?, nan? is the real numbers

* libguile/numbers.c (scm_inf_p, scm_finite_p, scm_nan_p): The domain of
  these functions is the real numbers.  Error on other input.

* doc/ref/api-data.texi (Reals and Rationals): Update the documentation
  accordingly.

* test-suite/tests/numbers.test ("finite?", "inf?"): Update tests.

13 years agoRemove useless code from do_divide
Mark H Weaver [Wed, 26 Jan 2011 07:50:03 +0000 (02:50 -0500)]
Remove useless code from do_divide

* libguile/numbers.c (do_divide): Remove code which handled a case
  that never occurs: a zero bignum.

13 years agoOptimize scm_exact_p by making use of SCM_INEXACTP
Mark H Weaver [Wed, 26 Jan 2011 14:36:05 +0000 (09:36 -0500)]
Optimize scm_exact_p by making use of SCM_INEXACTP

* libguile/numbers.c (scm_exact_p): Optimize by making use of the
  SCM_INEXACTP macro.
  (scm_inexact_p): Move it next to scm_exact_p, and add else's.

* test-suite/tests/numbers.test: Add test cases for `exact?'
  and `inexact?' applied to infinities and NaNs.

13 years agoImplement `finite?' in core and fix R6RS `finite?' and `infinite?'
Mark H Weaver [Wed, 26 Jan 2011 14:34:02 +0000 (09:34 -0500)]
Implement `finite?' in core and fix R6RS `finite?' and `infinite?'

* libguile/numbers.c (scm_finite_p): Add new predicate `finite?' from
  R6RS to guile core, which returns #t if and only if its argument is
  neither infinite nor a NaN.  Note that this is not the same as (not
  (inf? x)) or (not (infinite? x)), since NaNs are neither finite nor
  infinite.

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

* module/rnrs/base.scm: Import `inf?' as `infinite?' instead of
  reimplementing it.  Previously, the R6RS implementation of
  `infinite?' did not detect non-real complex infinities, nor did it
  throw exceptions for non-numbers.  (Note that NaNs _are_ considered
  numbers by scheme, despite their name).

  Import `finite?' instead of reimplementing it.  Previously, the R6RS
  implementation of `finite?' returned #t for both NaNs and non-real
  complex infinities, in violation of R6RS.

* NEWS: Add NEWS entries, and reorganize existing numerics-related
  entries together under one subheading.

* doc/ref/api-data.texi (Real and Rational Numbers): Add docs for
  `finite?' and scm_finite_p.

13 years agoAdd SCM_INUM1 to numbers.h, and make use of it and SCM_INUM0 in numbers.c
Mark H Weaver [Tue, 25 Jan 2011 23:58:47 +0000 (18:58 -0500)]
Add SCM_INUM1 to numbers.h, and make use of it and SCM_INUM0 in numbers.c

* libguile/numbers.h: Add SCM_INUM1, a name for the fixnum 1.  This is
  analogous to SCM_INUM0, a name for 0, which already existed.

* libguile/numbers.c: Change occurrences of SCM_I_MAKINUM (0) and
  SCM_I_MAKINUM (1) to SCM_INUM0 and SCM_INUM1, respectively.

13 years agoFix NEWS entry regarding changes to `expt' for zero base
Mark H Weaver [Tue, 25 Jan 2011 23:53:36 +0000 (18:53 -0500)]
Fix NEWS entry regarding changes to `expt' for zero base

NEWS: Fix NEWS entry regarding changes to `expt' when base is zero

13 years agoDo not apply `inf?' or `nan?' to strings
Mark H Weaver [Tue, 25 Jan 2011 23:35:22 +0000 (18:35 -0500)]
Do not apply `inf?' or `nan?' to strings

* module/ice-9/format.scm (format): Test to make sure an argument is a
  number before applying `inf?' and `nan?' to it.  Formerly, format
  would call `inf?' and `nan?' on arguments that might be either a
  number or a string, although those predicates should ideally throw an
  exception when applied to non-number objects.

13 years agoFix incorrect FUNC_NAME for scm_current_processor_count
Mark H Weaver [Tue, 25 Jan 2011 23:29:47 +0000 (18:29 -0500)]
Fix incorrect FUNC_NAME for scm_current_processor_count

* libguile/posix.c (scm_current_processor_count):
  Fix incorrect FUNC_NAME (was s_scm_total_processor_count)

13 years agofix guile-tools getopt
Andy Wingo [Thu, 27 Jan 2011 17:18:10 +0000 (18:18 +0100)]
fix guile-tools getopt

* meta/guile-tools.in (getopt): Define a local version of getopt that
  stops parsing options when it sees a non-option.

13 years agofix THANKS
Andy Wingo [Thu, 27 Jan 2011 12:13:23 +0000 (13:13 +0100)]
fix THANKS

* THANKS: Fix.

13 years agofor mmap objcodes, store the fd in the third word, as a scheme int
Andy Wingo [Thu, 27 Jan 2011 12:11:02 +0000 (13:11 +0100)]
for mmap objcodes, store the fd in the third word, as a scheme int

This leaves space for native code.

* libguile/objcodes.h (SCM_OBJCODE_NATIVE_CODE)
  (SCM_SET_OBJCODE_NATIVE_CODE): Reserve the fourth word of objcode for
  "native code", whatever that means.

* libguile/objcodes.c: Update a comment.
  (make_objcode_by_mmap): Put the fd in the third word.

13 years agoobjcode type is an enumeration, not flags
Andy Wingo [Thu, 27 Jan 2011 11:44:53 +0000 (12:44 +0100)]
objcode type is an enumeration, not flags

* libguile/objcodes.h (SCM_OBJCODE_TYPE_MMAP)
  (SCM_OBJCODE_TYPE_BYTEVECTOR, SCM_OBJCODE_TYPE_SLICE)
  (SCM_OBJCODE_TYPE_STATIC): Enumerate objcode types instead of
  expressing them as flags.
  (SCM_OBJCODE_TYPE): Type is held in bits 8-15.
  (SCM_OBJCODE_FLAGS): Flags are now shifted by 16 bits, not 8.
  (SCM_MAKE_OBJCODE_TAG): New helper.

* libguile/continuations.c (STATIC_OBJCODE_TAG):
* libguile/control.c (STATIC_OBJCODE_TAG):
* libguile/foreign.c (STATIC_OBJCODE_TAG):
* libguile/gsubr.c (STATIC_OBJCODE_TAG):
* libguile/smob.c (STATIC_OBJCODE_TAG):
* libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice)
  (scm_bytecode_to_objcode): : Use SCM_MAKE_OBJCODE_TAG.

13 years agoguile-tools gracefully errors for missing scripts
Andy Wingo [Thu, 27 Jan 2011 10:24:22 +0000 (11:24 +0100)]
guile-tools gracefully errors for missing scripts

* meta/guile-tools.in (find-script): Use the #:ensure arg of
  resolve-module.
  (main): Display a comprehensible error message if we don't find a
  script.

13 years agoguile-tools uses getopt-long
Andy Wingo [Thu, 27 Jan 2011 10:15:01 +0000 (11:15 +0100)]
guile-tools uses getopt-long

* meta/guile-tools.in: Use getopt-long.

13 years agoguile-tools uses srfi-1
Andy Wingo [Thu, 27 Jan 2011 09:57:18 +0000 (10:57 +0100)]
guile-tools uses srfi-1

* meta/guile-tools.in (guile-tools): Use srfi-1 here, now that we can.

13 years agofix error handling in variable-ref family of instructions
Andy Wingo [Thu, 27 Jan 2011 09:49:51 +0000 (10:49 +0100)]
fix error handling in variable-ref family of instructions

* libguile/vm-i-system.c (variable-ref, variable-set, variable-bound?):
  Check that the argument is actually a variable.  Thanks to Kevin
  Holmes for the report.

* libguile/vm-engine.c (vm_engine): Error handling down here.

* THANKS: Update.

13 years agoUse `scm_from_latin1_stringn' in `objcodes.c'.
Ludovic Courtès [Wed, 26 Jan 2011 23:16:54 +0000 (00:16 +0100)]
Use `scm_from_latin1_stringn' in `objcodes.c'.

* libguile/objcodes.c (make_objcode_by_mmap): Use
  `scm_from_latin1_stringn', not `scm_from_locale_stringn', to display
  the invalid cookie in the error case.