* doc/ref/api-data.texi (String Comparison): Remove documentation for
scm_i_string{,_ci}_{equal,less,leq,gr,geq}_p, which are not only
internal functions but static, and thus unusable by external code.
* doc/ref/api-compound.texi
* doc/ref/api-evaluation.texi
* doc/ref/api-foreign.texi
* doc/ref/api-io.texi
* doc/ref/posix.texi
* doc/ref/srfi-modules.texi: Add missing parentheses and commas to definitions
of C functions.
* doc/ref/api-data.texi: Change from @deffn to @deftypefn for C function
with arguments not of SCM type.
* doc/ref/api-data.texi (String Modification): Change
(define y "abcdefg") => (define y (string-copy "abcdefg"))
before mutating the string bound to y in the example code.
Reported by Dmitry Chestnykh <dmitry@codingrobots.com>.
Fixes <http://debbugs.gnu.org/10070>.
* libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not
`memcpy'.
* test-suite/tests/bytevectors.test ("2.2 General
Operations")["bytevector-copy! overlapping"]: New test.
* doc/ref/api-data.texi (Bytevector Manipulation): Mention possible
overlapping.
* doc/ref/api-data.texi (Exact and Inexact Numbers): doc for scm_is_exact
and scm_is_inexact
* libguile/numbers.c (scm_is_exact, scm_is_inexact): new functions
* libguile/numbers.h: declarations for scm_is_exact and scm_is_inexact
* test/suite/standalone/test-conversion.c (test_is_exact, test_is_inexact):
new tests
* doc/ref/api-data.texi (Conversion to/from C): In descriptions of
scm_to_stringn and scm_to_{latin1,utf8,utf32}, clarify that the
returned length is in units of bytes or code points, not characters.
Also change NULL to @code{NULL} in a few places.
* libguile/numbers.c (scm_exact_integer_sqrt): New C procedure to
compute exact integer square root and remainder.
(scm_i_exact_integer_sqrt): New Scheme procedure `exact-integer-sqrt'
from the R6RS, imported into core guile.
* libguile/numbers.h: Add prototypes.
* module/rnrs/base.scm: Remove broken stub implementation, which would
fail badly when applied to large integers.
* doc/ref/api-data.texi: Add documentation.
* doc/ref/r6rs.texi: Change documentation for `exact-integer-sqrt' to a
stub that xrefs the core docs, as is done for other operations
available in core.
* test-suite/tests/numbers.test: Add tests.
* NEWS: Add news entries.
* doc/ref/api-data.texi (Arithmetic): `floor-remainder' is equivalent to
the R5RS `modulo' when the arguments are integers. Previously,
equivalence was claimed only for exact integers. Similarly for
`truncate-quotient' and `truncate-remainder' compared with the R5RS
`quotient' and `remainder'.
* libguile/strings.c (scm_to_locale_stringn, scm_from_locale_stringn):
Use the encoding of the current locale, not of the current i/o ports.
Also use the current conversion strategy.
* doc/ref/api-data.texi (Conversion to/from C): Update docs.
* libguile/keywords.c (scm_from_latin1_keyword, scm_from_utf8_keyword):
New functions appropriate for use when keyword name is a constant.
(scm_from_locale_keyword, scm_from_locale_keywordn): Change formal
parameter from `str' to `name'.
* libguile/keywords.h: Add prototypes for new functions. Change formal
parameter of scm_from_locale_keyword* from `str' to `name'.
* doc/ref/api-data.texi: Document new functions. Remind users that
scm_from_locale_keyword should not be used when the name is a C string
constant. Change formal parameter from `str' to `name'.
* doc/ref/api-data.texi (Conversion to/from C): Document
scm_from_latin1_string, scm_from_utf8_string, and
scm_from_utf32_string. Remind readers that these functions should be
used to convert C string constants, and that scm_from_locale_string is
_not_ appropriate for that purpose.
(Symbol Primitives): Document scm_from_latin1_symbol and
scm_from_utf8_symbol. Remind readers that these functions should be
used when the specified names are C string constants, and that
scm_from_locale_symbol is _not_ appropriate for that purpose.
* doc/ref/api-data.texi (Arithmetic): The R5RS `quotient', `remainder',
and `modulo' operators are exact-integer-only operators. `modulo' is
equivalent to `floor-remainder', not `floor-quotient'.
* libguile/numbers.c (scm_euclidean_divide, scm_centered_divide): Change
API to return two values via output arguments of type (SCM *), instead
of packing into a values object.
(scm_i_euclidean_divide, scm_i_centered_divide): New internal wrappers
that call the above functions and pack the result into a values
object.
* libguile/numbers.h: Change prototypes to reflect new API.
* doc/ref/api-data.h (Arithmetic): Update manual.
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.
* 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.
* 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.
* 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.
Suggested by Noah Lavine <noah.b.lavine@gmail.com>.
* doc/ref/api-data.texi (String Searching): Mention the return value of
`string-index', `string-index-right', and `string-rindex' when no
match is found.
* libguile/srfi-13.c (scm_string_index, scm_string_index_right,
scm_string_rindex): Adjust docstring accordingly.
* libguile/srfi-13.h:
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Swap
char_pred and s argument order, to comply with SRFI-13. There is a
back-compat shim that will detect programs that used the old,
erroneous interface, while giving a warning.
* doc/ref/api-data.texi: Update docs.
Because that probably isn't where people will look for it.
Thanks to Noah Lavine for the idea.
* doc/ref/api-regex.texi (Regular Expressions): New file, containing
the regex doc (promoted one level) that used to be in api-data.texi.
* doc/ref/guile.texi (API Reference): Include new file, and add menu
entry for the new section.
* THANKS: Add Noah.
* doc/ref/api-evaluation.texi (Scheme Read): Fold all reader options
docs into this section. Undocument read-options-interface.
(Scheme Write): New section for `write' and `display', and the print
options. print-enable/print-disable are not documented, as there are
no boolean print options. print-options-interface is likewise
undocumented.
* doc/ref/api-options.texi: Remove discussion of options in
general. Move read options to Scheme Read, and print options to Scheme
Write.
* doc/ref/api-io.texi (Reading): Link to Scheme Read.
(Writing): Move write and display to Scheme Write, and link there.
* doc/ref/srfi-modules.texi:
* doc/ref/api-debug.texi:
* doc/ref/api-data.texi: Update xrefs.
* doc/ref/api-data.texi: document scm_to_stringn, scm_from_stringn,
scm_to_latin1_stringn, and scm_from_latin1_stringn
* libguile/strings.h (scm_to_stringn): make public
(scm_to_latin1_stringn): new declaration
(scm_from_latin1_stringn): new declaration
* libguile/strings.c (scm_to_latin1_stringn): new function
(scm_from_latin1_stringn): new function
Now the random number generator state can be obtained in external
(i.e. `read'/`write'-able) form via the new procedure
`random-state->external'. An externalized state can be reinstantiated by
calling `external->random-state'.
* libguile/random.c (scm_i_init_rstate_scm, scm_i_expose_rstate): New
internal functions.
* libguile/random.c (scm_c_make_rstate_scm, scm_external_to_random_state,
scm_random_state_to_external): New public functions.
* libguile/random.h: Add prototypes for the above functions.
* libguile/random.h (scm_t_rng): Add new fields `init_rstate_scm' and
`expose_rstate'.
* libguile/random.c (scm_init_random): Initialize the new fields in
`scm_the_rng'.
R6RS character hex escapes do not conflict with legacy Guile octal
character escapes, so they can be enabled by default.
* libguile/read.c (scm_read_character): modified
* test-suite/tests/reader.test: modify character escape tests
* doc/ref/api-data.texi: modified
* doc/ref/api-options.texi: modified
Conflicts:
doc/ref/api-procedures.texi
doc/ref/misc-modules.texi
(Caused by me removing `@page' from a couple of sections that have been modified
by others.)
* doc/ref/api-macros.texi: New file, documenting macros. Removed some
old cruft, and started documenting hygienic macros.
* doc/ref/api-procedures.texi: Moved macro things out of here.
* doc/ref/guile.texi: Separate macros from procedures.
* doc/ref/api-data.texi: Update some xrefs.
* doc/ref/Makefile.am: Add api-macros.texi.
* doc/ref/api-data.texi (Bytevectors as Strings): Remove obsolete
footnote on the lack of Unicode support.
* test-suite/tests/bytevectors.test ("2.9 Operations on
Strings")["string->utf8 [latin-1]", "utf8->string [latin-1]"]: Remove
use of `with-latin1-locale'.
["string->utf32 [Greek]"]: New tests.