[plt-scheme] cadr: expects argument of type <cadrable value>;

From: Derrick Wippler (thrawn01 at gmail.com)
Date: Thu Jan 14 11:38:04 EST 2010

I'm new to Scheme so hopefully this will be simple to solve, I'm
trying to compile the following project using mzscheme


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


Derrick J. Wippler

Posted on the users mailing list.