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

From: David Brown (plt at davidb.org)
Date: Thu Jan 14 11:45:56 EST 2010

On Thu, Jan 14, 2010 at 10:38:04AM -0600, Derrick Wippler wrote:

>> (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

Actually, it is, but only in a subtle way.  The braces around the
'given {...}' part indicate that this is a list created with mcons.
In order to decompose a mutable list, you need to use the m variants
of the list ops.  The doesn't appear to be the long forms of the
names, so instead of (mcadr foo), you could say (mcar (mcdr foo)), or
just define mcadr.

Unfortunately, the use of mutable pairs is pervasive, since they are a
distinct type from the immutable pairs.

Is the code compatible with r5rs or r6rs?  That might be the easiest
way to get mutable pairs.


Posted on the users mailing list.