chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] array-lib : empty arrays advertise indices that they can


From: Terrence Brannon
Subject: [Chicken-users] array-lib : empty arrays advertise indices that they cannot be indexed by
Date: Thu, 4 Oct 2007 05:59:43 -0400

Re: http://www.call-with-current-continuation.org/eggs/array-lib.html

We read: (make-array [<prototype>]) will construct an empty array, not
a rank 0 array. Such arrays cannot be used with any setter or getter.
However, property queries will work, and they can be used as a
PROTOTYPE.

So I have several questions based on this information:

1 - what is meant by getter or setter? what particular functions? I'm
guessing array-ref might be one. And the one of most interest to me,
array-for-each-index

2 - Since the docs make the distinction between an empty array and a
rank-0 array:
  a - how do these two things differ?
  b - how can a rank-0 array be created since (make-array) does not do it?

3 - It seems unusual to me that the array created by (make-array)
produces its indices, yet throws an error when you use the indices it
produces. I'm trying to create some generic code which works for
arrays of any rank and it works fine for arrays of rank 1 and greater,
but for "rank-0" arrays, it is failing similar to below. Rank-0 is in
quotes because my empty arrays are not rank-0 per the docs. But I
would definitely like a rank-0 array, or at least something which does
not write it's own death sentence when queried for its indices :)


(define e (make-array))
(define (a vec)
  (array-for-each-index
   (lambda (*indices*)
     (display *indices*)
     )
   vec
   ))

(define (b vec)
  (array-for-each-index
   (lambda (*indices*)
     (display (array-ref vec *indices*))
     )
   vec
   ))

(a e) ; displays 0
(b e) ; Error: (array-ref) out of range: (0)




reply via email to

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