Improve extensibility of `expt' and `integer-expt'
authorMark H Weaver <mhw@netris.org>
Sun, 30 Jan 2011 15:51:36 +0000 (10:51 -0500)
committerAndy Wingo <wingo@pobox.com>
Mon, 31 Jan 2011 20:58:27 +0000 (21:58 +0100)
commitbfe1f03aac3df63a5e4b0b670338a728c7b45cf7
tree8157c2496c4ca9ff4928f650b453f53096724b5e
parent05a5e5d6d075ddd12cbec98679fa3808caf1c2ef
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
NEWS
libguile/numbers.c
test-suite/tests/numbers.test