Apply in icyc
srgx opened this issue ยท 5 comments
srgx commented
Function 'apply' is not working properly in icyc
(import (scheme base) (scheme write))
(define (exfun a b . rst)
(list a b rst))
(display (apply exfun 1 2 '(3 4 5))) (newline)
; (1 3 (4 5))
; (display (apply cons '(5 (1 2 3)))) (newline)
; error
(display (apply cons '(5 '(1 2 3)))) (newline)
; (5 1 2 3)
yorickhardy commented
I don't know if this helps much, but for a bit more context, the second issue seems to be limited to primitives:
cyclone> (define (kons a b) (cons a b))
ok
cyclone> (apply kons '(5 (1 2 3)))
(5 1 2 3)
justinethier commented
Good find, thanks for the report @srgx!
justinethier commented
Added debug output and see the following.
Why is analyze
called again after analyze-quoted
? Need to investigate further...
cyclone> (display (apply cons '(5 (1 2 3)))) (newline)
/* (analyze (display (apply cons (quote (5 (1 2 3)))))) */
/* (analyze display) */
/* (analyze (apply cons (quote (5 (1 2 3))))) */
/* (analyze apply) */
/* (analyze cons) */
/* (analyze (quote (5 (1 2 3)))) */
/* (analyze-quoted (quote (5 (1 2 3)))) */
/* (analyze (<primitive cons> 5 (1 2 3))) */
/* (analyze <primitive cons>) */
/* (analyze 5) */
/* (analyze (1 2 3)) */
/* (analyze 1) */
/* (analyze 2) */
/* (analyze 3) */Error: Unknown procedure type -- EXECUTE-APPLICATION: 1
cyclone>
/* (analyze (newline)) */
/* (analyze newline) */
and alternatively:
cyclone> (define (kons a b) (cons a b))
cyclone> (apply kons '(5 (1 2)))
/* (analyze (apply kons (quote (5 (1 2))))) */
/* (analyze apply) */
/* (analyze kons) */
/* (analyze (quote (5 (1 2)))) */
/* (analyze-quoted (quote (5 (1 2)))) */
/* (analyze ((procedure (a b) ...) 5 (quote (1 2)))) */
/* (analyze (procedure (a b) ...)) */
/* (analyze 5) */
/* (analyze (quote (1 2))) */
/* (analyze-quoted (quote (1 2))) */
justinethier commented
Possible fix above, need to vet more and possibly clean up associated code. Also need to add some unit tests for this case before wrapping everything up.
justinethier commented
We are good to go on this, closing.