unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Fix for `make-uniform-array'
@ 2006-02-01  8:28 Ludovic Courtès
  2006-02-02 20:53 ` Kevin Ryde
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2006-02-01  8:28 UTC (permalink / raw)


Hi,

The following patch fixes `make-uniform-array' in 1.7 so that it
properly initializes vectors according to the FILL argument --- see the
discussion on `guile-user'[0].

The `#\nul' case mentioned in that thread remains somewhat incompatible
but perhaps this is not too much of a problem.  Hmm...

  $ guile-1.6
  guile> (make-uniform-array #\nul 10)
  #y(0 0 0 0 0 0 0 0 0 0)

  $ ./pre-inst-guile  # i.e., 1.7
  guile> (define a (make-uniform-array #\nul 10))
  ERROR: Wrong type (expecting exact integer): #\nul
  ABORT: (wrong-type-arg)

This may require fixing `dimensions->uniform-array'.  What do you think?

Thanks,
Ludovic.

[0] http://lists.gnu.org/archive/html/guile-user/2006-01/msg00086.html


2006-01-01  Ludovic Courtès  <ludovic.courtes@laas.fr>

	* deprecated.scm (make-uniform-array): Fill the returned vector
	with PROT.


--- orig/ice-9/deprecated.scm
+++ mod/ice-9/deprecated.scm
@@ -173,8 +173,8 @@
 
 (define make-uniform-vector dimensions->uniform-array)
 
-(define (make-uniform-array prot . args)
-  (dimensions->uniform-array args prot))
+(define (make-uniform-array prot . bounds)
+  (dimensions->uniform-array bounds prot prot))
  
 (define (list->uniform-vector prot lst)
   (list->uniform-array 1 prot lst))



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix for `make-uniform-array'
  2006-02-01  8:28 [PATCH] Fix for `make-uniform-array' Ludovic Courtès
@ 2006-02-02 20:53 ` Kevin Ryde
  2006-02-12  1:08   ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2006-02-02 20:53 UTC (permalink / raw)


ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
>   $ ./pre-inst-guile  # i.e., 1.7
>   guile> (define a (make-uniform-array #\nul 10))
>   ERROR: Wrong type (expecting exact integer): #\nul
>   ABORT: (wrong-type-arg)

That's a bug.  In 1.6 you could pass chars to array-set! (and fill)
with a #\nul (ie. byte) uniform array, that should still be possible.

(I thought I fixed something close to that another time too, before
the big srfi-4 integration.  Second time lucky maybe ...)

> -(define (make-uniform-array prot . args)
> -  (dimensions->uniform-array args prot))
> +(define (make-uniform-array prot . bounds)
> +  (dimensions->uniform-array bounds prot prot))

Thanks, I applied that.

But if you're fixing a bug then you should make a test case which
exercises the problem, to show it's really fixed (which I guess it's
not yet fully fixed in this case), and catch it if it rears its ugly
head again.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix for `make-uniform-array'
  2006-02-02 20:53 ` Kevin Ryde
@ 2006-02-12  1:08   ` Marius Vollmer
  0 siblings, 0 replies; 3+ messages in thread
From: Marius Vollmer @ 2006-02-12  1:08 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>>
>>   $ ./pre-inst-guile  # i.e., 1.7
>>   guile> (define a (make-uniform-array #\nul 10))
>>   ERROR: Wrong type (expecting exact integer): #\nul
>>   ABORT: (wrong-type-arg)
>
> That's a bug.  In 1.6 you could pass chars to array-set! (and fill)
> with a #\nul (ie. byte) uniform array, that should still be possible.

Yes and no.  It's a bug that (make-uniform-array #\nul 10) fails, but
it is was a conscious incompatible change that uniform numeric arrays
can no longer store characters.

The bug was actually in scm_dimensions_to_uniform_array: when the
'fill' parameter was unspecified, the prototype should have been used
for filling, but was not.

Thus, I made the following changes:

    * deprecated.scm (make-uniform-array): Don't pass the prototype as
    the fill value, dimensions->uniform-array will do the right thing
    now.  See scm_dimensions_to_uniform_array why we need to be tricky
    about the fill value.

    * unif.c (scm_dimensions_to_uniform_array): Use the prototype for
    filling when the fill parameter is omitted, as documented, but
    turn #\nul into 0 since s8 arrays (signified by a #\nul prototype)
    can not store characters.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-12  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-01  8:28 [PATCH] Fix for `make-uniform-array' Ludovic Courtès
2006-02-02 20:53 ` Kevin Ryde
2006-02-12  1:08   ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).