[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: uniform-array-read!
From: |
Ludovic Courtès |
Subject: |
Re: uniform-array-read! |
Date: |
Tue, 31 Jan 2006 14:42:07 +0100 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
Hi,
William Xu <address@hidden> writes:
> Is the following the correct way of using `uniform-array-read!'? Seems
> it simply hangs there..
>
> (let ((ar (make-uniform-array #\nul length)))
> (uniform-array-read! ar sockfd))
In your example, it can very well be hanging because there is nothing to
read from SOCKFD (e.g., it's making a blocking `read' system call
beneath).
Using Guile 1.7:
guile> (define a (make-uniform-array #\nul 10))
guile> (uniform-array-read! a (open-input-string (string #\001 #\002 #\003)))
3
guile> a
#s8(1 2 3 32 51 10 -102 96 48 10)
guile>
IOW, it seems to work fine --- except that:
1. The array is not properly initialized;
2. The result is not a string as one would expect from the Guile 1.6
manual[*] (in fact it could hardly be a string since internally
strings may not contain null characters AFAIK).
So 1.7 is _not_ compatible with 1.6 in that respect. I guess we need to
fix this.
In 1.7, `make-uniform-array' is deprecated and replaced by
`make-typed-array' (BTW, this deprecation is not currently documented in
the 1.7 manual):
-- Scheme Procedure: make-typed-array type fill bound ...
-- C Function: scm_make_typed_array (type, fill, bounds)
Create and return an array that has as many dimensions as there are
BOUNDs and (maybe) fill it with FILL.
Hope this helps,
Ludovic.
[*] From node `Uniform Arrays':
Unshared uniform arrays of characters with a single zero-based dimension
are identical to strings:
(make-uniform-array #\a 3) =>
"aaa"
Unshared uniform arrays of booleans with a single zero-based dimension
are identical to *Note bit-vectors: Bit Vectors.
(make-uniform-array #t 3) =>
#*111