ashinn / chibi-scheme

Official chibi-scheme repository
Other
1.21k stars 142 forks source link

SRFI 231: list*->array has incorrect argument signature #900

Closed gambiteer closed 1 year ago

gambiteer commented 1 year ago

I tried:

heine:~/programs/chibi-scheme> env LD_LIBRARY_PATH=/usr/local/chibi/lib /usr/local/chibi/bin/chibi-scheme
> (import (srfi 231))

(define (pp arg) (display arg) (newline))

(pp 'array-append)

(let* ((cont #f)
       (call-cont #t)
       (domain (make-interval '#(2 2)))
       (B (list*->array 2 '((1 2) (3 4))))
       (A_ (lambda (i j)
             (call-with-current-continuation
              (lambda (c)
                (if (= i j 0)
                    (set! cont c))
                1))))
       (A (make-array domain A_))
       (array-list '()))
  (set! array-list (cons (array-append 1 (list A B)) array-list))
  (pp 'printing)
  (for-each (lambda (A) (pp (array->list* A))) array-list)
  (if call-cont
      (begin
        (set! call-cont #f)
        (cont 4)))
  (pp (apply eq? array-list)))
> > array-append
> ERROR in flatten on line 491 of file ./lib/srfi/231/transforms.scm: car: not a pair: 2

The definition of list*->array in transforms.scm begins

(define (list*->array nested-ls . o)

but the signature in the SRFI is

Procedure: list*->array d nested-list [ storage-class [ mutable? [ safe? ] ] ]

i.e., the dimension is passed as the first argument, so the entries of the array can be lists themselves.

ashinn commented 1 year ago

I already have this and a few other fixes locally, but Chibi's SRFI 231 support is still a WIP. You'll find lots of issues with it.

gambiteer commented 1 year ago

OK, I'll close this as premature.

ashinn commented 1 year ago

No need to close for being premature :sweat_smile: Pushed a fix anyway, sorry for the delay.