udem-dlteam / ribbit

A portable, compact and extensible Scheme implementation that is fully R4RS compliant. This includes closures, I/O, tail calls, first-class continuations and a Read Eval Print Loop (REPL). The R4RS Scheme REPL fits inside 6.5Kb !
BSD 3-Clause "New" or "Revised" License
489 stars 43 forks source link

Using a chicken-compiled rsc crashes #13

Open shawnw opened 2 years ago

shawnw commented 2 years ago
$ csc -o rsc.chicken -O2 rsc.scm 
$ RSC_SCHEME_INTERPRETER=csi ./rsc -c ./rsc.chicken -t c -l max test.scm

Error: (cdr) bad argument type: ()

    Call history:

    rsc.scm:172: make-table   
    rsc.scm:566: rib      
    rsc.scm:1737: cmd-line    
    rsc.scm:98: chicken.process-context#command-line-arguments    
    rsc.scm:1737: parse-cmd-line        <--
*** compilation error:

Issues is that chicken's (command-line-arguments)doesn't include the name of the program, and rsc ends up trying to take the cdr of an empty list. PR with a fix coming shortly.

ec1oud commented 6 months ago

Currently on dev it doesn't even build:

chicken-csc -o rsc-chicken  rsc.scm

Warning: Wrong number of arguments
  In file `rsc.scm:2349',
  In procedure `read-from-file',
  In procedure call:

    (read-line port)

  Procedure `read-line' is called with 1 argument but 2 arguments are expected.

  Procedure `read-line' has this type:

    (procedure (* *) . *)

Error: cannot coerce inexact literal `4294967296' to fixnum

Error: shell command terminated with non-zero exit status 256: '/usr/bin/chicken' 'rsc.scm' -output-file 'rsc-chicken.c'

Don't you want to use (chicken io) instead of a self-defined version? http://api.call-cc.org/5/doc/chicken/io/read-line vs

(cond-expand

 (gambit (begin))

 (else

   (define (read-line port sep)  ;; <--- doesn't seem to be optional here
     (let loop ((rev-chars '()))
       (let ((c (read-char port)))
         (if (or (eof-object? c) (eqv? c sep))
             (list->string (reverse rev-chars))
             (loop (cons c rev-chars))))))
leo-ard commented 5 months ago

Thanks for letting me know, I'll look into it ! I just added some CI to avoid those problems in the future (https://github.com/udem-dlteam/ribbit/pull/60). If we manage to make it work, we could add chicken to the CI pipeline