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.
* 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'.
* 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.
* 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.
* 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.
* 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.
* 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>.
* 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'.
* 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.
* 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.
* doc/ref/misc-modules.texi (Formatted Output): Adapt ~f documentation
to indicate that the output will always have a decimal point. Thanks
to Fu-gangqiang for the report.
* THANKS: Update.
This is so that compiling the same code on environments with different
locale settings yields the same result.
* module/system/base/compile.scm (compile-file): When ENC if #f, default
to "UTF-8" instead of `(fluid-ref %default-port-encoding)'.
* doc/ref/api-evaluation.texi (Compilation): Document the default output
file name and default source file encoding for `compile-file' and
`guile-tools compile'.
* libguile/numbers.c (scm_is_integer): Infinities are not integers, per
the R6RS.
(scm_even_p, scm_odd_p): Passing an infinity to even? or odd? is an
error.
* test-suite/tests/numbers.test ("integer?"): Adapt test.
("expt"): Add tests for +inf.0 and -inf.0 exponents.
* NEWS: Add NEWS entries.
Thanks to Mark Harig for pointing this out and suggesting the text.
* doc/ref/scheme-scripts.texi (Invoking Guile): Mention --autocompile
and --no-autocompile.
Thanks to Mark Harig for pointing these out.
* doc/guile.1: Remove mention of the tutorial, since it no longer
exists (as a separate document). Document the -q option.
* THANKS: Add Mark Harig.
* doc/ref/goops.texi (The Metaobject Protocol): Bring forward to
before `Class Options', and add intro text to explain why. All of
the sections now remaining are ones where the MOP is more likely to
be relevant than not.
* doc/ref/goops.texi (GOOPS Object Miscellany): New section, combining
previous `Object Comparison', `Cloning Objects' and `Write and
Display'. Replace `Object Comparison' text with something that
makes sense. Add a snippet to the end of the write/display section.
* doc/ref/goops.texi (Introspection): Make a bit snappier.
(Classes): Add intro. Remove "the" and "metaobject" everywhere.
Remove `class-environment', since I don't know what it's useful for.
(Instances): Remove implementation notes.
(Built-in classes): Merge with `Instances'. Reorder text points.
(Generic Functions): Add intro. Remove "the" and "metaobject"
everywhere.
(Generic Function Methods): Merge with `Generic Functions'.
* doc/ref/goops.texi (Introspection): Move to after `Generic Functions
and Methods'. The idea is to have all of that sections that make
sense without needing to understand the MOP, before sections that
really depend on the MOP.
* doc/ref/goops.texi (Methods and Generic Functions): More explanation
of generic function invocation. Created (or moved) subsections here
to cover material on the following that was previously spread elsewhere:
accessors; extending primitives; merging generics; generic function
examples; handling invocation errors. Edited for clarity throughout.
(Generic functions and methods, Example): Nodes deleted, with their
material incorporated above.
(Class Precedence List): Edited to improve clarity.
(Sorting Methods): New subsection.