guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-14-155-g2


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-14-155-g2d7908d
Date: Mon, 31 Jan 2011 22:17:11 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=2d7908db7eecc13999d90200e7b8e511138cb4db

The branch, master has been updated
       via  2d7908db7eecc13999d90200e7b8e511138cb4db (commit)
       via  bfe1f03aac3df63a5e4b0b670338a728c7b45cf7 (commit)
      from  05a5e5d6d075ddd12cbec98679fa3808caf1c2ef (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2d7908db7eecc13999d90200e7b8e511138cb4db
Author: Andy Wingo <address@hidden>
Date:   Mon Jan 31 23:20:32 2011 +0100

    update NEWS
    
    * NEWS: Update.

commit bfe1f03aac3df63a5e4b0b670338a728c7b45cf7
Author: Mark H Weaver <address@hidden>
Date:   Sun Jan 30 10:51:36 2011 -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

-----------------------------------------------------------------------

Summary of changes:
 NEWS                          |   91 +++++++++++++++++++++++++++++++++++++++++
 libguile/numbers.c            |   28 ++++++++-----
 test-suite/tests/numbers.test |   19 +++++++--
 3 files changed, 123 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index 33e49a4..3770cde 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,86 @@ latest prerelease, and a full NEWS corresponding to 1.8 -> 
2.0.
 
 Changes in 1.9.15 (since the 1.9.14 prerelease):
 
+** Formally deprecate omission of port to `format'
+    
+It used to be that you could omit passing a port to `format', in some
+cases.  This still works, but has been formally deprecated.
+    
+** ECMAScript fixes
+
+Noah Lavine and Kan-Ru Chen noticed and fixed a number of embarrassing
+bugs in object creation, unicode literals in strings, empty function
+bodies, non-breaking whitespace, and numeric literals.
+
+** `(web ...)' changes
+
+*** `parse-uri', `unparse-uri' now called `string->uri', `uri->string'
+    
+*** `uri-decode' takes `#:encoding' keyword argument, not `#:charset'
+
+*** HTTP header representation change
+
+Guile properly garbage-collects symbols, so there's no need to read some
+headers as symbols and some as strings: all header names are symbols
+now.  The same goes for many key-value constructs in headers.  Guile
+parses the challenge/authentication headers now, as well.  Header decl
+objects are no longer exposed to the user.
+
+*** Request and response bodies are always bytevectors
+
+Reading bodies as latin-1 strings was a cute hack, but not general, so
+Guile's only official fetch-me-the-body procedures return bytevectors
+now.
+
+** New procedures: scm_{to,from}_{utf8,latin1}_symbol{n,}
+** New procedures: scm_{to,from}_{utf8,utf32,latin1}_symbol{n,}
+    
+These new procedures convert to and from string representations in
+particular encodings.
+
+Basically, continue to use locale encoding for user input, user output,
+or interacting with the C library.  Use latin1 for ASCII, and for
+literals in source code.  Use utf8 for interaction with modern libraries
+which deal in UTF-8.  Use utf32 for interaction with utf32-using
+libraries.  Otherwise use scm_to_stringn or scm_from_stringn with a
+specific encoding.
+
+Also, scm_from_latin1_symbol is quite a bit faster now.
+
+** Documentation updates
+
+The GOOPS manual saw a lot of work, as well as documentation for the
+`(web ...)' modules.
+
+** Guile uses iconv directly for reading from and writing to ports.
+
+[What does this mean for users?]
+
+** Source files default to UTF-8.
+
+If source files do not specify their encoding via a `coding:' block,
+the default encoding is UTF-8, instead of being taken from the current
+locale.
+
+** Man page updates
+
+Thanks to Mark Harig for many suggestions regarding the manual page,
+which is getting better.
+
+** Interactive Guile installs the current locale.
+    
+Instead of leaving the user in the "C" locale, running the Guile REPL
+installs the current locale.  [FIXME xref?]
+
+** `recv!', `recvfrom!', `send', `sendto' now deal in bytevectors
+
+These socket procedures now take bytevectors as arguments, instead of
+strings.  There is some deprecated string support, however.
+
+** New foreign API: `define-wrapped-pointer-type', `pointer?'
+    
+See "Foreign Types", for more.
+
 ** Changes and bugfixes in numerics code
 
 *** Added two new sets of fast quotient and remainder operators
@@ -58,6 +138,17 @@ integer-expt.  This is more correct, and conforming to 
R6RS, but seems
 to be incompatible with R5RS, which would return 0 for all non-zero
 values of N.
 
+*** `expt' and `integer-expt' are more generic, less strict
+
+When raising to an exact non-negative integer exponent, `expt' and
+`integer-expt' are now able to exponentiate any object that can be
+multiplied using `*'.  They can also raise an object to an exact
+negative integer power if its reciprocal can be taken using `/'.
+In order to allow this, the type of the first argument is no longer
+checked when raising to an exact integer power.  If the exponent is 0
+or 1, the first parameter is not manipulated at all, and need not
+even support multiplication.
+
 *** Infinities are no longer integers, nor rationals
 
 scm_integer_p `integer?' and scm_rational_p `rational?' now return #f
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 41d178b..d08d15f 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -3052,23 +3052,29 @@ SCM_DEFINE (scm_integer_expt, "integer-expt", 2, 0, 0,
   int i2_is_big = 0;
   SCM acc = SCM_I_MAKINUM (1L);
 
-  SCM_VALIDATE_NUMBER (SCM_ARG1, n);
-  if (!SCM_I_INUMP (k) && !SCM_BIGP (k))
+  /* Specifically refrain from checking the type of the first argument.
+     This allows us to exponentiate any object that can be multiplied.
+     If we must raise to a negative power, we must also be able to
+     take its reciprocal. */
+  if (!SCM_LIKELY (SCM_I_INUMP (k)) && !SCM_LIKELY (SCM_BIGP (k)))
     SCM_WRONG_TYPE_ARG (2, k);
 
-  if (scm_is_true (scm_zero_p (n)))
-    {
-      if (scm_is_true (scm_zero_p (k)))  /* 0^0 == 1 per R5RS */
-       return acc;        /* return exact 1, regardless of n */
-      else if (scm_is_true (scm_positive_p (k)))
+  if (SCM_UNLIKELY (scm_is_eq (k, SCM_INUM0)))
+    return SCM_INUM1;  /* n^(exact0) is exact 1, regardless of n */
+  else if (SCM_UNLIKELY (scm_is_eq (n, SCM_I_MAKINUM (-1L))))
+    return scm_is_false (scm_even_p (k)) ? n : SCM_INUM1;
+  /* The next check is necessary only because R6RS specifies different
+     behavior for 0^(-k) than for (/ 0).  If n is not a scheme number,
+     we simply skip this case and move on. */
+  else if (SCM_NUMBERP (n) && scm_is_true (scm_zero_p (n)))
+    {
+      /* k cannot be 0 at this point, because we
+        have already checked for that case above */
+      if (scm_is_true (scm_positive_p (k)))
        return n;
       else  /* return NaN for (0 ^ k) for negative k per R6RS */
        return scm_nan ();
     }
-  else if (scm_is_eq (n, acc))
-    return acc;
-  else if (scm_is_eq (n, SCM_I_MAKINUM (-1L)))
-    return scm_is_false (scm_even_p (k)) ? n : acc;
 
   if (SCM_I_INUMP (k))
     i2 = SCM_I_INUM (k);
diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test
index 0d711b0..d85e44c 100644
--- a/test-suite/tests/numbers.test
+++ b/test-suite/tests/numbers.test
@@ -3110,8 +3110,21 @@
 
 (with-test-prefix "expt"
   (pass-if (documented? expt))
-  (pass-if-exception "non-numeric base" exception:wrong-type-arg
-                     (expt #t 0))
+
+  ;;
+  ;; expt no longer requires its first argument to be a scheme number,
+  ;; for the sake of extensibility, and expt calls integer-expt for
+  ;; integer powers.  To raise to a positive power, all that is required
+  ;; is that it can be multiplied using `*'.  For negative powers we
+  ;; must also be able to find the reciprocal.  If we try to raise #t to
+  ;; any power other than 0 or 1 it may throw an exception, depending on
+  ;; whether * has been defined for #t.  However, when raising to the 0
+  ;; or 1 power, the first argument is not manipulated at all.
+  ;;
+  ;; (pass-if-exception "non-numeric base" exception:wrong-type-arg
+  ;;                    (expt #t 0))
+  ;;
+
   (pass-if (eqv? 1 (expt 0 0)))
   (pass-if (eqv? 1 (expt 0.0 0)))
   (pass-if (eqv? 1.0 (expt 0 0.0)))
@@ -3277,8 +3290,6 @@
 (with-test-prefix "integer-expt"
   (pass-if (documented? integer-expt))
 
-  (pass-if-exception "non-numeric base" exception:wrong-type-arg
-                     (integer-expt #t 0))
   (pass-if-exception "2^+inf" exception:wrong-type-arg
     (integer-expt 2 +inf.0))
   (pass-if-exception "2^-inf" exception:wrong-type-arg


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]