[Guile-commits] 07/07: (wip) give a handle into format used in exceptions

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit 6118d9dd0cc7733ca71c6b803a942a15f463663a
Author: Daniel Llorens 
Date:   Tue Feb 7 12:42:20 2017 +0100

(wip) give a handle into format used in exceptions
---
 module/ice-9/boot-9.scm | 43 +++
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 229d917..5e1b98f 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -339,6 +339,7 @@ a-cont
 ;; let format alias simple-format until the more complete version is loaded
 
 (define format simple-format)
+(define exception-format simple-format)
 
 ;; this is scheme wrapping the C code so the final pred call is a tail call,
 ;; per SRFI-13 spec
@@ -770,7 +771,7 @@ information is unavailable."
((not (car args)) 1)
(else 0
  (else
-  (format (current-error-port) "guile: uncaught throw to ~a: ~a\n"
+  (exception-format (current-error-port) "guile: uncaught throw to ~a: 
~a\n"
   key args)
   (primitive-exit 1
 
@@ -873,8 +874,8 @@ for key @var{k}, then invoke @var{thunk}."
   (let ((filename (or (cadr source) ""))
 (line (caddr source))
 (col (cdddr source)))
-(format port "~a:~a:~a: " filename (1+ line) col))
-  (format port "ERROR: "
+(exception-format port "~a:~a:~a: " filename (1+ line) col))
+  (exception-format port "ERROR: "
 
   (set! set-exception-printer!
 (lambda (key proc)
@@ -883,7 +884,7 @@ for key @var{k}, then invoke @var{thunk}."
   (set! print-exception
 (lambda (port frame key args)
   (define (default-printer)
-(format port "Throw to key `~a' with args `~s'." key args))
+(exception-format port "Throw to key `~a' with args `~s'." key 
args))
 
   (when frame
 (print-location frame port)
@@ -892,7 +893,7 @@ for key @var{k}, then invoke @var{thunk}."
   (lambda () (frame-procedure-name frame))
   (lambda _ #f
   (when name
-(format port "In procedure ~a:\n" name
+(exception-format port "In procedure ~a:\n" name
 
   (print-location frame port)
   (catch #t
@@ -902,7 +903,9 @@ for key @var{k}, then invoke @var{thunk}."
 (printer port key args default-printer)
 (default-printer
 (lambda (k . args)
-  (format port "Error while printing exception.")))
+  (exception-format
+   port "Error while printing exception `~a`: `~a' with args [~s]"
+   key k args)))
   (newline port)
   (force-output port
 
@@ -916,38 +919,38 @@ for key @var{k}, then invoke @var{thunk}."
 (apply (case-lambda
  ((subr msg args . rest)
   (if subr
-  (format port "In procedure ~a: " subr))
-  (apply format port msg (or args '(
+  (exception-format port "In procedure ~a: " subr))
+  (apply exception-format port msg (or args '(
  (_ (default-printer)))
args))
 
   (define (syntax-error-printer port key args default-printer)
 (apply (case-lambda
  ((who what where form subform . extra)
-  (format port "Syntax error:\n")
+  (exception-format port "Syntax error:\n")
   (if where
   (let ((file (or (assq-ref where 'filename) "unknown file"))
 (line (and=> (assq-ref where 'line) 1+))
 (col (assq-ref where 'column)))
-(format port "~a:~a:~a: " file line col))
-  (format port "unknown location: "))
+(exception-format port "~a:~a:~a: " file line col))
+  (exception-format port "unknown location: "))
   (if who
-  (format port "~a: " who))
-  (format port "~a" what)
+  (exception-format port "~a: " who))
+  (exception-format port "~a" what)
   (if subform
-  (format port " in subform ~s of ~s" subform form)
+  (exception-format port " in subform ~s of ~s" subform form)
   (if form
-  (format port " in form ~s" form
+  (exception-format port " in form ~s" form
  (_ (default-printer)))
args))
 
   (define (keyword-error-printer port key args default-printer)
 (let ((message (cadr args))
   (faulty  (car (cadddr args ; I won't do it again, I promise.
-  (format port "~a: ~s" message faulty)))
+  (exception-format port "~a: ~s" message faulty)))
 
   (define 

[Guile-commits] 03/07: Fix sort, sort! for arrays with nonzero lower bound

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit 79bdd186cc7c9825716bb9d0156fdef478b778f3
Author: Daniel Llorens 
Date:   Mon Feb 13 12:58:34 2017 +0100

Fix sort, sort! for arrays with nonzero lower bound

* module/ice-9/arrays.scm (array-copy): New function, export.
* module/Makefile.am: Install (ice-9 arrays).
* doc/ref/api-data.texi: Add documentation for (ice-9 arrays).
* libguile/quicksort.i.c: Use signed bounds throughout.
* libguile/sort.c (scm_restricted_vector_sort_x): Fix error calls. Fix
  calls to quicksort.
* test-suite/tests/sort.test: Actually test that the sorted results
  match the original data. Test cases for non-zero base index arrays for
  sort, sort!, and stable-sort!.
---
 doc/ref/api-data.texi  |  32 +++
 libguile/quicksort.i.c |  48 
 libguile/sort.c|  43 ++-
 module/Makefile.am |   1 +
 module/ice-9/arrays.scm|  50 ++---
 test-suite/tests/sort.test | 133 -
 6 files changed, 185 insertions(+), 122 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index e0c756d..0905236 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -7496,10 +7496,6 @@ same type, and have corresponding elements which are 
either
 @code{equal?} (@pxref{Equality}) in that all arguments must be arrays.
 @end deffn
 
-@c  FIXME: array-map! accepts no source arrays at all, and in that
-@c  case makes calls "(proc)".  Is that meant to be a documented
-@c  feature?
-@c
 @c  FIXME: array-for-each doesn't say what happens if the sources have
 @c  different index ranges.  The code currently iterates over the
 @c  indices of the first and expects the others to cover those.  That
@@ -7507,14 +7503,15 @@ same type, and have corresponding elements which are 
either
 @c  documented feature?
 
 @deffn {Scheme Procedure} array-map! dst proc src @dots{}
-@deffnx {Scheme Procedure} array-map-in-order! dst proc src1 @dots{} srcN
+@deffnx {Scheme Procedure} array-map-in-order! dst proc src @dots{}
 @deffnx {C Function} scm_array_map_x (dst, proc, srclist)
-Set each element of the @var{dst} array to values obtained from calls
-to @var{proc}.  The value returned is unspecified.
+Set each element of the @var{dst} array to values obtained from calls to
+@var{proc}.  The list of @var{src} arguments may be empty.  The value
+returned is unspecified.
 
-Each call is @code{(@var{proc} @var{elem1} @dots{} @var{elemN})},
-where each @var{elem} is from the corresponding @var{src} array, at
-the @var{dst} index.  @code{array-map-in-order!} makes the calls in
+Each call is @code{(@var{proc} @var{elem} @dots{})}, where each
+@var{elem} is from the corresponding @var{src} array, at the
+@var{dst} index.  @code{array-map-in-order!} makes the calls in
 row-major order, @code{array-map!} makes them in an unspecified order.
 
 The @var{src} arrays must have the same number of dimensions as
@@ -7566,6 +7563,21 @@ $\left(\matrix{%
 @end example
 @end deffn
 
+An additional array function is available in the module
+@code{(ice-9 arrays)}. It can be used with:
+
+@example
+(use-modules (ice-9 arrays))
+@end example
+
+@deffn {Scheme Procedure} array-copy src
+Return a new array with the same elements, type and shape as
+@var{src}. However, the array increments may not be the same as those of
+@var{src}. In the current implementation, the returned array will be in
+row-major order, but that might change in the future. Use
+@code{array-copy!} on an array of known order if that is a concern.
+@end deffn
+
 @node Shared Arrays
 @subsubsection Shared Arrays
 
diff --git a/libguile/quicksort.i.c b/libguile/quicksort.i.c
index cf1742e..5982672 100644
--- a/libguile/quicksort.i.c
+++ b/libguile/quicksort.i.c
@@ -27,7 +27,7 @@
reduces the probability of selecting a bad pivot value and eliminates
certain extraneous comparisons.
 
-   3. Only quicksorts NR_ELEMS / MAX_THRESH partitions, leaving insertion sort
+   3. Only quicksorts (UBND-LBND+1) / MAX_THRESH partitions, leaving insertion 
sort
to order the MAX_THRESH items within each partition.  This is a big win,
since insertion sort is faster for small, mostly sorted array segments.
 
@@ -54,33 +54,29 @@
 #defineSTACK_NOT_EMPTY  (stack < top)
 
 static void
-NAME (VEC_PARAM size_t nr_elems, INC_PARAM SCM less)
+NAME (VEC_PARAM ssize_t lbnd, ssize_t ubnd, INC_PARAM SCM less)
 {
   /* Stack node declarations used to store unfulfilled partition obligations. 
*/
   typedef struct {
-size_t lo;
-size_t hi;
+ssize_t lo;
+ssize_t hi;
   } stack_node;
 
   static const char s_buggy_less[] = "buggy less predicate used when sorting";
 
-  if (nr_elems == 0)
-/* Avoid lossage with unsigned arithmetic below.  */
-return;
-
-  if (nr_elems > MAX_THRESH)
+  if (ubnd-lbnd+1 > MAX_THRESH)
 {
-  size_t lo = 0;

[Guile-commits] 02/07: Remove documentation on uniform-vector-read!, uniform-vector-write

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit 45ef6fb9b8014da7f1d21bb0e28070d6145c15ba
Author: Daniel Llorens 
Date:   Mon Feb 13 13:21:59 2017 +0100

Remove documentation on uniform-vector-read!, uniform-vector-write

* NEWS: Add specific removal notice.
* doc/ref/api-data.texi: Remove documentation on uniform-vector-read!,
  uniform-vector-write.
---
 NEWS  |  7 +++
 doc/ref/api-data.texi | 33 -
 2 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/NEWS b/NEWS
index 2126813..9e1647a 100644
--- a/NEWS
+++ b/NEWS
@@ -739,6 +739,13 @@ All code deprecated in Guile 2.0 has been removed.  See 
older NEWS, and
 check that your programs can compile without linker warnings and run
 without runtime warnings.  See "Deprecation" in the manual.
 
+In particular, the following functions, which were deprecated in 2.0.10
+but not specifically mentioned earlier in this file, have been removed:
+
+*** `uniform-vector-read!' and `uniform-vector-write' have been
+removed. Use `get-bytevector-n!' and `put-bytevector' from (rnrs io
+ports) instead.
+
 ** Remove miscellaneous unused interfaces
 
 We have removed accidentally public, undocumented interfaces that we
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index bf46d5c..e0c756d 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -7566,39 +7566,6 @@ $\left(\matrix{%
 @end example
 @end deffn
 
-@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]]
-@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end)
-Attempt to read all elements of array @var{ra}, in lexicographic order, as
-binary objects from @var{port_or_fd}.
-If an end of file is encountered,
-the objects up to that point are put into @var{ra}
-(starting at the beginning) and the remainder of the array is
-unchanged.
-
-The optional arguments @var{start} and @var{end} allow
-a specified region of a vector (or linearized array) to be read,
-leaving the remainder of the vector unchanged.
-
-@code{uniform-array-read!} returns the number of objects read.
-@var{port_or_fd} may be omitted, in which case it defaults to the value
-returned by @code{(current-input-port)}.
-@end deffn
-
-@deffn {Scheme Procedure} uniform-array-write ra [port_or_fd [start [end]]]
-@deffnx {C Function} scm_uniform_array_write (ra, port_or_fd, start, end)
-Writes all elements of @var{ra} as binary objects to
-@var{port_or_fd}.
-
-The optional arguments @var{start}
-and @var{end} allow
-a specified region of a vector (or linearized array) to be written.
-
-The number of objects actually written is returned.
-@var{port_or_fd} may be
-omitted, in which case it defaults to the value returned by
-@code{(current-output-port)}.
-@end deffn
-
 @node Shared Arrays
 @subsubsection Shared Arrays
 



[Guile-commits] 01/07: Replace uniform-vector-read benchmark with bytevector-io benchmark

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit 7a3aa7b650e747c83b0cf116df2d4ec7b9cd2b46
Author: Daniel Llorens 
Date:   Mon Feb 13 12:11:50 2017 +0100

Replace uniform-vector-read benchmark with bytevector-io benchmark

* benchmark-suite/benchmarks/uniform-vector-read.bm:
  Remove; uniform-vector-read! and uniform-vector-write were deprecated
  in 2.0 and are have been removed in 2.1.
* benchmark-suite/benchmarks/bytevector-io.bm: New benchmark.
* benchmark-suite/Makefile.am: Run the new benchmark.
---
 benchmark-suite/Makefile.am|  2 +-
 .../{uniform-vector-read.bm => bytevector-io.bm}   | 29 +++---
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/benchmark-suite/Makefile.am b/benchmark-suite/Makefile.am
index 1222121..47bd036 100644
--- a/benchmark-suite/Makefile.am
+++ b/benchmark-suite/Makefile.am
@@ -1,5 +1,6 @@
 SCM_BENCHMARKS = benchmarks/0-reference.bm \
 benchmarks/arithmetic.bm   \
+benchmarks/bytevector-io.bm\
 benchmarks/bytevectors.bm  \
 benchmarks/chars.bm\
 benchmarks/continuations.bm\
@@ -13,7 +14,6 @@ SCM_BENCHMARKS = benchmarks/0-reference.bm\
 benchmarks/srfi-13.bm  \
 benchmarks/structs.bm  \
 benchmarks/subr.bm \
-benchmarks/uniform-vector-read.bm  \
 benchmarks/vectors.bm  \
 benchmarks/vlists.bm   \
 benchmarks/write.bm\
diff --git a/benchmark-suite/benchmarks/uniform-vector-read.bm 
b/benchmark-suite/benchmarks/bytevector-io.bm
similarity index 64%
rename from benchmark-suite/benchmarks/uniform-vector-read.bm
rename to benchmark-suite/benchmarks/bytevector-io.bm
index 01b7478..7ae7c0e 100644
--- a/benchmark-suite/benchmarks/uniform-vector-read.bm
+++ b/benchmark-suite/benchmarks/bytevector-io.bm
@@ -1,6 +1,6 @@
-;;; uniform-vector-read.bm --- Exercise binary I/O primitives.  -*- Scheme -*-
+;;; bytevector-io.bm --- Exercise bytevector I/O primitives.  -*- Scheme -*-
 ;;;
-;;; Copyright (C) 2008 Free Software Foundation, Inc.
+;;; Copyright (C) 2008, 2017 Free Software Foundation, Inc.
 ;;;
 ;;; This program is free software; you can redistribute it and/or
 ;;; modify it under the terms of the GNU Lesser General Public License
@@ -17,9 +17,10 @@
 ;;; not, write to the Free Software Foundation, Inc., 51 Franklin
 ;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
 
-(define-module (benchmarks uniform-vector-read)
+(define-module (benchmarks bytevector-io)
   :use-module (benchmark-suite lib)
-  :use-module (srfi srfi-4))
+  :use-module (rnrs io ports)
+  :use-module (rnrs bytevectors))
 
 (define file-name
   (tmpnam))
@@ -30,24 +31,22 @@
 (define buf
   (make-u8vector %buffer-size))
 
-(define str
-  (make-string %buffer-size))
-
 
-(with-benchmark-prefix "uniform-vector-read!"
+(with-benchmark-prefix "bytevector i/o"
 
-  (benchmark "uniform-vector-write" 4000
+  (benchmark "put-bytevector" 4000
 (let ((output (open-output-file file-name)))
-  (uniform-vector-write buf output)
+  (put-bytevector output buf)
   (close output)))
 
-  (benchmark "uniform-vector-read!" 2
+  (benchmark "get-bytevector-n!" 2
 (let ((input (open-input-file file-name)))
   (setvbuf input 'none)
-  (uniform-vector-read! buf input)
+  (get-bytevector-n! input buf 0 (bytevector-length buf))
   (close input)))
 
-  (benchmark "string port" 5000
-(let ((input (open-input-string str)))
-  (uniform-vector-read! buf input)
+  (benchmark "get-bytevector-n" 2
+(let ((input (open-input-file file-name)))
+  (setvbuf input 'none)
+  (get-bytevector-n input (bytevector-length buf))
   (close input



[Guile-commits] 04/07: Support non-zero lower bounds in array-slice-for-each

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit bb2ab2ed5be4414f5a4428c763f2af69efbe62da
Author: Daniel Llorens 
Date:   Mon Feb 13 13:49:35 2017 +0100

Support non-zero lower bounds in array-slice-for-each

* libguile/array-map.c (scm_array_slice_for_each): Support non-zero
  lower bounds. Fix error messages.
* test-suite/tests/array-map.test: Test scm_array_slice_for_each with
  non-zero lower bound argument.
---
 libguile/array-map.c| 22 +-
 test-suite/tests/array-map.test |  8 
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/libguile/array-map.c b/libguile/array-map.c
index c2825bc..b6529c0 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -677,6 +677,7 @@ SCM_DEFINE (scm_array_slice_for_each, 
"array-slice-for-each", 2, 0, 1,
 "@end lisp")
 #define FUNC_NAME s_scm_array_slice_for_each
 {
+  SCM xargs = args;
   int const N = scm_ilength (args);
   int const frank = scm_to_int (frame_rank);
   int ocd;
@@ -740,9 +741,9 @@ SCM_DEFINE (scm_array_slice_for_each, 
"array-slice-for-each", 2, 0, 1,
   assert((pool0+pool_size==pool) && "internal error");
 #undef AFIC_ALLOC_ADVANCE
 
-  for (n=0; scm_is_pair(args); args=scm_cdr(args), ++n)
+  for (n=0, xargs=args; scm_is_pair(xargs); xargs=scm_cdr(xargs), ++n)
 {
-  args_[n] = scm_car(args);
+  args_[n] = scm_car(xargs);
   scm_array_get_handle(args_[n], ah+n);
   as[n] = scm_array_handle_dims(ah+n);
   rank[n] = scm_array_handle_rank(ah+n);
@@ -750,29 +751,24 @@ SCM_DEFINE (scm_array_slice_for_each, 
"array-slice-for-each", 2, 0, 1,
   /* checks */
   msg = NULL;
   if (frank<0)
-msg = "bad frame rank";
+msg = "bad frame rank ~S, ~S";
   else
 {
   for (n=0; n!=N; ++n)
 {
   if (rank[n]typed-array 'f64 2 '((9 1) (7 8



[Guile-commits] branch wip-exception-truncate updated (0b0ee66 -> 6118d9d)

2017-02-27 Thread Daniel Llorens
lloda pushed a change to branch wip-exception-truncate
in repository guile.

  discards  0b0ee66   (wip) give a handle into format used in exceptions
  discards  e989cf0   Remove scm_generalized_vector_get_handle
  discards  258715c   Fix bitvectors and non-zero lower bound arrays in 
truncated-print
  discards  d8d0680   Support non-zero lower bounds in array-slice-for-each
  discards  c3c3ad6   Fix sort, sort! for arrays with nonzero lower bound
  discards  50f1ad6   Remove documentation on uniform-vector-read!, 
uniform-vector-write
  discards  98020c7   Replace uniform-vector-read benchmark with bytevector-io 
benchmark
  adds  f8dd4f6   Explain why no native accessors for `s8' and `u8' exist
   new  7a3aa7b   Replace uniform-vector-read benchmark with bytevector-io 
benchmark
   new  45ef6fb   Remove documentation on uniform-vector-read!, 
uniform-vector-write
   new  79bdd18   Fix sort, sort! for arrays with nonzero lower bound
   new  bb2ab2e   Support non-zero lower bounds in array-slice-for-each
   new  f87f2c8   Fix bitvectors and non-zero lower bound arrays in 
truncated-print
   new  530df23   Remove scm_generalized_vector_get_handle
   new  6118d9d   (wip) give a handle into format used in exceptions

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (0b0ee66)
\
 N -- N -- N   refs/heads/wip-exception-truncate (6118d9d)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omits" are not gone; other references still
refer to them.  Any revisions marked "discards" are gone forever.

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/ref/api-data.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)



[Guile-commits] 05/07: Fix bitvectors and non-zero lower bound arrays in truncated-print

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit f87f2c81c942ad56fc06d6753efb7daece7a6d70
Author: Daniel Llorens 
Date:   Tue Feb 21 12:23:35 2017 +0100

Fix bitvectors and non-zero lower bound arrays in truncated-print

* module/ice-9/arrays.scm (array-print-prefix): New private function.
* libguile/arrays.c (scm_i_print_array): Reuse (array-print-prefix) from
  (ice-9 arrays). Make sure to release the array handle.
* module/ice-9/pretty-print.scm (truncated-print): Support
  bitvectors.
  Don't try to guess the array prefix but call array-print-prefix from
  (ice-9 arrays) instead.
  Fix call to print-sequence to support non-zero lower bound arrays.
* test-suite/tests/arrays.test: Test that arrays print properly.
* test-suite/tests/print.test: Test truncated-print with bitvectors,
  non-zero lower bound arrays.
---
 libguile/arrays.c | 48 +++
 module/ice-9/arrays.scm   | 40 -
 module/ice-9/pretty-print.scm | 24 --
 test-suite/tests/arrays.test  | 55 +++-
 test-suite/tests/print.test   | 58 +--
 5 files changed, 169 insertions(+), 56 deletions(-)

diff --git a/libguile/arrays.c b/libguile/arrays.c
index 8b8bc48..682fbf6 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -908,50 +908,17 @@ scm_i_print_array_dimension (scm_t_array_handle *h, int 
dim, int pos,
   return 1;
 }
 
-/* Print an array.
-*/
-
 int
 scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
 {
   scm_t_array_handle h;
-  size_t i;
-  int print_lbnds = 0, zero_size = 0, print_lens = 0;
+  int d;
 
+  scm_call_2 (scm_c_private_ref ("ice-9 arrays", "array-print-prefix"),
+  array, port);
+  
   scm_array_get_handle (array, );
 
-  scm_putc ('#', port);
-  if (SCM_I_ARRAYP (array))
-scm_intprint (h.ndims, 10, port);
-  if (h.element_type != SCM_ARRAY_ELEMENT_TYPE_SCM)
-scm_write (scm_array_handle_element_type (), port);
-
-  for (i = 0; i < h.ndims; i++)
-{
-  if (h.dims[i].lbnd != 0)
-   print_lbnds = 1;
-  if (h.dims[i].ubnd - h.dims[i].lbnd + 1 == 0)
-   zero_size = 1;
-  else if (zero_size)
-   print_lens = 1;
-}
-
-  if (print_lbnds || print_lens)
-for (i = 0; i < h.ndims; i++)
-  {
-   if (print_lbnds)
- {
-   scm_putc ('@', port);
-   scm_intprint (h.dims[i].lbnd, 10, port);
- }
-   if (print_lens)
- {
-   scm_putc (':', port);
-   scm_intprint (h.dims[i].ubnd - h.dims[i].lbnd + 1,
- 10, port);
- }
-  }
-
   if (h.ndims == 0)
 {
   /* Rank zero arrays, which are really just scalars, are printed
@@ -977,10 +944,13 @@ scm_i_print_array (SCM array, SCM port, scm_print_state 
*pstate)
   scm_putc ('(', port);
   scm_i_print_array_dimension (, 0, 0, port, pstate);
   scm_putc (')', port);
-  return 1;
+  d = 1;
 }
   else
-return scm_i_print_array_dimension (, 0, 0, port, pstate);
+d = scm_i_print_array_dimension (, 0, 0, port, pstate);
+
+  scm_array_handle_release ();
+  return d;
 }
 
 void
diff --git a/module/ice-9/arrays.scm b/module/ice-9/arrays.scm
index 2c04b2e..f03eb35 100644
--- a/module/ice-9/arrays.scm
+++ b/module/ice-9/arrays.scm
@@ -17,9 +17,13 @@
 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
 
 (define-module (ice-9 arrays)
+  #:use-module (rnrs io ports)
+  #:use-module (srfi srfi-1)
   #:export (array-copy))
 
-; This is actually defined in boot-9.scm, apparently for b.c.
+;; This is actually defined in boot-9.scm, apparently for backwards
+;; compatibility.
+
 ;; (define (array-shape a)
 ;;   (map (lambda (ind) (if (number? ind) (list 0 (+ -1 ind)) ind))
 ;;(array-dimensions a)))
@@ -30,3 +34,37 @@
 (array-copy! a b)
 b))
 
+
+;; Printing arrays
+
+;; The dimensions aren't printed out unless they cannot be deduced from
+;; the content, which happens only when certain axes are empty. #:dims?
+;; can be used to force this printing. An array with all the dimensions
+;; printed out is still readable syntax, this can be useful for
+;; truncated-print.
+
+(define* (array-print-prefix a port #:key dims?)
+  (put-char port #\#)
+  (display (array-rank a) port)
+  (let ((t (array-type a)))
+(unless (eq? #t t)
+  (display t port)))
+  (let ((ss (array-shape a)))
+(let loop ((s ss) (slos? #f) (szero? #f) (slens? dims?))
+  (define lo caar)
+  (define hi cadar)
+  (if (null? s)
+(when (or slos? slens?)
+  (pair-for-each (lambda (s)
+   (when slos?
+ (put-char port #\@)
+ (display (lo s) port))
+   (when slens?
+ 

[Guile-commits] 06/07: Remove scm_generalized_vector_get_handle

2017-02-27 Thread Daniel Llorens
lloda pushed a commit to branch wip-exception-truncate
in repository guile.

commit 530df2310b8946639691481ad6ebe3b368d5050d
Author: Daniel Llorens 
Date:   Mon Feb 13 13:41:45 2017 +0100

Remove scm_generalized_vector_get_handle

This was deprecated in 2.0.9 (118ff892be199f0af359d1b027645d4783a364ec).

* libguile/bitvectors.c (scm_bitvector_writable_elements): Replace
  scm_generalized_vector_get_handle.
  Remove unnecessary #includes.
* libguile/vectors.c (scm_vector_writable_elements): Replace
  scm_generalized_vector_get_handle.
  Remove unnecessary #includes.
* libguile/random.c (scm_random_normal_vector_x): Replace
  scm_generalized_vector_get_handle.
* libguile/generalized-vectors.h, libguile/generalized-vectors.c
  (scm_generalized_vector_get_handle): Remove.
  Remove unnecessary #includes.
* NEWS: Add removal notice.
---
 NEWS   |  4 
 libguile/bitvectors.c  | 10 ++
 libguile/generalized-vectors.c | 13 -
 libguile/generalized-vectors.h |  7 ++-
 libguile/random.c  |  8 +++-
 libguile/vectors.c | 15 ---
 6 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/NEWS b/NEWS
index 9e1647a..40343fb 100644
--- a/NEWS
+++ b/NEWS
@@ -746,6 +746,10 @@ but not specifically mentioned earlier in this file, have 
been removed:
 removed. Use `get-bytevector-n!' and `put-bytevector' from (rnrs io
 ports) instead.
 
+*** `scm_generalized_vector_get_handle' has been removed. Use
+`scm_array_get_handle' to get a handle and `scm_array_handle_rank'
+to check the rank.
+
 ** Remove miscellaneous unused interfaces
 
 We have removed accidentally public, undocumented interfaces that we
diff --git a/libguile/bitvectors.c b/libguile/bitvectors.c
index 7a4ed9b..0dde67b 100644
--- a/libguile/bitvectors.c
+++ b/libguile/bitvectors.c
@@ -27,12 +27,9 @@
 
 #include "libguile/_scm.h"
 #include "libguile/__scm.h"
-#include "libguile/strings.h"
 #include "libguile/array-handle.h"
 #include "libguile/bitvectors.h"
 #include "libguile/arrays.h"
-#include "libguile/generalized-vectors.h"
-#include "libguile/srfi-4.h"
 
 /* Bit vectors. Would be nice if they were implemented on top of bytevectors,
  * but alack, all we have is this crufty C.
@@ -204,7 +201,12 @@ scm_bitvector_writable_elements (SCM vec,
 size_t *lenp,
 ssize_t *incp)
 {
-  scm_generalized_vector_get_handle (vec, h);
+  scm_array_get_handle (vec, h);
+  if (1 != scm_array_handle_rank (h))
+{
+  scm_array_handle_release (h);
+  scm_wrong_type_arg_msg (NULL, 0, vec, "rank 1 bit array");
+}
   if (offp)
 {
   scm_t_array_dim *dim = scm_array_handle_dims (h);
diff --git a/libguile/generalized-vectors.c b/libguile/generalized-vectors.c
index 276b9d8..68c1042 100644
--- a/libguile/generalized-vectors.c
+++ b/libguile/generalized-vectors.c
@@ -27,8 +27,6 @@
 #include "libguile/_scm.h"
 #include "libguile/__scm.h"
 
-#include "libguile/array-handle.h"
-#include "libguile/generalized-arrays.h"
 #include "libguile/generalized-vectors.h"
 
 
@@ -70,17 +68,6 @@ SCM_DEFINE (scm_make_generalized_vector, 
"make-generalized-vector", 2, 1, 0,
 #undef FUNC_NAME
 
 void
-scm_generalized_vector_get_handle (SCM vec, scm_t_array_handle *h)
-{
-  scm_array_get_handle (vec, h);
-  if (scm_array_handle_rank (h) != 1)
-{
-  scm_array_handle_release (h);
-  scm_wrong_type_arg_msg (NULL, 0, vec, "vector");
-}
-}
-
-void
 scm_init_generalized_vectors ()
 {
 #include "libguile/generalized-vectors.x"
diff --git a/libguile/generalized-vectors.h b/libguile/generalized-vectors.h
index 77d6272..9df8a0c 100644
--- a/libguile/generalized-vectors.h
+++ b/libguile/generalized-vectors.h
@@ -3,7 +3,8 @@
 #ifndef SCM_GENERALIZED_VECTORS_H
 #define SCM_GENERALIZED_VECTORS_H
 
-/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2013 
Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2013
+ * Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -24,15 +25,11 @@
 
 
 #include "libguile/__scm.h"
-#include "libguile/array-handle.h"
 
 
 
 /* Generalized vectors */
 
-SCM_API void scm_generalized_vector_get_handle (SCM vec,
-   scm_t_array_handle *h);
-
 SCM_API SCM scm_make_generalized_vector (SCM type, SCM len, SCM fill);
 SCM_INTERNAL void scm_i_register_vector_constructor (SCM type, SCM 
(*ctor)(SCM, SCM));
 
diff --git a/libguile/random.c b/libguile/random.c
index 1ee0459..a8ad075 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -621,7 +621,13 @@ SCM_DEFINE (scm_random_normal_vector_x, 
"random:normal-vector!", 1, 1, 0,
 state = SCM_VARIABLE_REF 

[Guile-commits] branch master updated (f261eaf -> f8dd4f6)

2017-02-27 Thread Andy Wingo
wingo pushed a change to branch master
in repository guile.

  from  f261eaf   Fix guild compile --to=cps / --from=cps
   new  f8dd4f6   Explain why no native accessors for `s8' and `u8' exist

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/ref/api-data.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)



[Guile-commits] 01/01: Explain why no native accessors for `s8' and `u8' exist

2017-02-27 Thread Andy Wingo
wingo pushed a commit to branch master
in repository guile.

commit f8dd4f67b5af9e80642a6b262f96049690a3e8bf
Author: Diogo F. S. Ramos 
Date:   Sun Feb 26 19:19:00 2017 -0300

Explain why no native accessors for `s8' and `u8' exist

* doc/ref/api-data.texi: Instead of saying it is obvious, explain why
  no native endianness accessors exist for the `s8' and `u8' variants.
---
 doc/ref/api-data.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 1b3170e..bf46d5c 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -6942,8 +6942,9 @@ Store @var{value} as an @var{n}-bit (signed) integer 
(where @var{n} is
 @end deffn
 
 Finally, a variant specialized for the host's endianness is available
-for each of these functions (with the exception of the @code{u8}
-accessors, for obvious reasons):
+for each of these functions (with the exception of the @code{u8} and
+@code{s8} accessors, as endianness is about byte order and there is only
+1 byte):
 
 @deffn {Scheme Procedure} bytevector-u16-native-ref bv index
 @deffnx {Scheme Procedure} bytevector-s16-native-ref bv index



[Guile-commits] Success: Hydra job gnu:guile-master:build.i686-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.i686-linux’ has changed from 
"Failed" to "Success".  For details, see

  https://hydra.nixos.org/build/49226339

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_without_threads.i686-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.i686-linux’ has 
changed from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/49226341

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_without_threads.x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.x86_64-linux’ 
has changed from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/49226340

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_clang.i686-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.i686-linux’ has changed 
from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/49226344

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_clang.x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.x86_64-linux’ has changed 
from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/49226337

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build.x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.x86_64-linux’ has changed from 
"Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/49226347

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2 on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job 
‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2’ (on 
x86_64-linux) has changed from "Failed" to "Failed with output".  For details, 
see

  https://hydra.nixos.org/build/49226349

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:build_enable_guile_debug on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_enable_guile_debug’ (on 
x86_64-linux) has changed from "Failed with output" to "Success".  For details, 
see

  https://hydra.nixos.org/build/49226343

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Success: Hydra job gnu:guile-master:tarball on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:tarball’ (on x86_64-linux) has 
changed from "Failed with output" to "Success".  For details, see

  https://hydra.nixos.org/build/49226346

Yay!

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_disable_networking on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_disable_networking’ (on 
x86_64-linux) has changed from "Dependency failed" to "Failed with output".  
For details, see

  https://hydra.nixos.org/build/49226046

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:coverage on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:coverage’ (on x86_64-linux) has 
changed from "Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226039

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build.x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.x86_64-linux’ has changed from 
"Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226043

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_clang.i686-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.i686-linux’ has changed 
from "Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226031

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.i686-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.i686-linux’ has 
changed from "Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226044

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_clang.x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_clang.x86_64-linux’ has changed 
from "Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226034

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed: Hydra job gnu:guile-master:build.i686-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.i686-linux’ has changed from 
"Dependency failed" to "Failed".  For details, see

  https://hydra.nixos.org/build/49226036

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2 on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job 
‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2’ (on 
x86_64-linux) has changed from "Dependency failed" to "Failed".  For details, 
see

  https://hydra.nixos.org/build/49226035

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:tarball on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:tarball’ (on x86_64-linux) has 
changed from "Failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226040

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_disable_deprecated_disable_discouraged on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job 
‘gnu:guile-master:build_disable_deprecated_disable_discouraged’ (on 
x86_64-linux) has changed from "Dependency failed" to "Failed with output".  
For details, see

  https://hydra.nixos.org/build/49226042

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.x86_64-darwin

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.x86_64-darwin’ 
has changed from "Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226033

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1 on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1’ (on 
x86_64-linux) has changed from "Dependency failed" to "Failed with output".  
For details, see

  https://hydra.nixos.org/build/49226047

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build.x86_64-darwin

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build.x86_64-darwin’ has changed from 
"Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226045

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_enable_guile_debug on x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_enable_guile_debug’ (on 
x86_64-linux) has changed from "Dependency failed" to "Failed with output".  
For details, see

  https://hydra.nixos.org/build/49226032

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed with output: Hydra job gnu:guile-master:build_without_threads.x86_64-linux

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:build_without_threads.x86_64-linux’ 
has changed from "Dependency failed" to "Failed with output".  For details, see

  https://hydra.nixos.org/build/49226038

Go forth and fix it.

Regards,

The Hydra build daemon.



[Guile-commits] Failed: Hydra job gnu:guile-master:tarball on x86_64-linux (and 14 others)

2017-02-27 Thread Hydra Build Daemon
Hi,

The status of Hydra job ‘gnu:guile-master:tarball’ (on x86_64-linux) has 
changed from "Success" to "Failed".  For details, see

  https://hydra.nixos.org/build/49187769

The following dependent jobs also failed:

* gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG=1 
(https://hydra.nixos.org/build/49187765)
* gnu:guile-master:build_clang.x86_64-linux 
(https://hydra.nixos.org/build/49187770)
* gnu:guile-master:build_disable_deprecated_disable_discouraged 
(https://hydra.nixos.org/build/49187767)
* gnu:guile-master:build_CPPFLAGS=_DSCM_DEBUG_TYPING_STRICTNESS=2 
(https://hydra.nixos.org/build/49187762)
* gnu:guile-master:coverage (https://hydra.nixos.org/build/49187761)
* gnu:guile-master:build_without_threads.i686-linux 
(https://hydra.nixos.org/build/49187756)
* gnu:guile-master:build_disable_networking 
(https://hydra.nixos.org/build/49187764)
* gnu:guile-master:build.x86_64-darwin (https://hydra.nixos.org/build/49187757)
* gnu:guile-master:build.i686-linux (https://hydra.nixos.org/build/49187755)
* gnu:guile-master:build.x86_64-linux (https://hydra.nixos.org/build/49187758)
* gnu:guile-master:build_enable_guile_debug 
(https://hydra.nixos.org/build/49187759)
* gnu:guile-master:build_without_threads.x86_64-linux 
(https://hydra.nixos.org/build/49187768)
* gnu:guile-master:build_without_threads.x86_64-darwin 
(https://hydra.nixos.org/build/49187754)
* gnu:guile-master:build_clang.i686-linux 
(https://hydra.nixos.org/build/49187766)

This may be due to 2 commits by Andy Wingo .

Go forth and fix them.

Regards,

The Hydra build daemon.