[plt-scheme] cadr: expects argument of type <cadrable value>;
I'm new to Scheme so hopefully this will be simple to solve, I'm
trying to compile the following project using mzscheme
http://www.ida.liu.se/~tobnu/scheme2llvm/
I resolved an issue with the current code using cons instead of mcons
but now I have an issue I can't resolve.
I'll paste the relevant code below
---------
(define (definition-value exp)
(if (symbol? (cadr exp))
(caddr exp)
(mcons 'lambda (mcons (cdadr exp) (cddr exp)))))
(define (fix-list lst)
(cond ((not (pair? lst)) (mcons lst '()))
(else (mcons (car lst) (fix-list (cdr lst))))))
(define exp `(llvm-define (and x y) (if x y (make-null))))
(define f-lambda (definition-value exp))
(define (lambda-parameters exp)
(if (list? (cadr exp)) (cadr exp) (fix-list (cadr exp))))
(lambda-parameters f-lambda)
----------
The error for that final line is:
cadr: expects argument of type <cadrable value>; given {lambda (x y) .
((if x y (make-null)))}
This error confuses me as the following repl output will illustrate
> (cadr `{lambda (x y) . ((if x y (make-null)))})
(x y)
> (cadr f-lambda)
cadr: expects argument of type <cadrable value>; given {lambda (x y) .
((if x y (make-null)))}
The error specifies the type cadr requires but does not explicitly
describe the type of the given argument. My assumption therefore is
scheme is NOT telling me the entire story, Can someone fill in the
gaps?
Thanks,
Derrick J. Wippler