chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] redefining cons,car,cdr in SICP


From: F. Wittenberger
Subject: Re: [Chicken-users] redefining cons,car,cdr in SICP
Date: Sat, 04 Dec 2010 14:56:29 +0100

Am Freitag, den 03.12.2010, 13:36 -0700 schrieb Alan Post:
> On Fri, Dec 03, 2010 at 09:03:15PM +0100, Jörg F. Wittenberger wrote:
> > Am Freitag, den 03.12.2010, 12:57 -0500 schrieb Hans Nowak:
> > > On Fri, Dec 3, 2010 at 12:33, David Steiner <address@hidden> wrote:
> > > > i'm reading SICP and practicing in chicken. in the book they redefine
> > > > cons, car and cdr using procedures:
> > > >
> > > > (define (cons x y)
> > > >  (define (dispatch m)
> > > >    (cond ((= m 0) x)
> > > >          ((= m 1) y)
> > > >          (else (error "Argument not 0 or 1 -- CONS" m))))
> > > >  dispatch)
> > > > (define (car z) (z 0))
> > > > (define (cdr z) (z 1))
> > > >
> > > > however it produces an error in chicken:
> > > >   Error: (caar) bad argument type: #<procedure (dispatch m)>
> > > >
> > > > why doesn't it work?
> > 
> > This is clearly a bug!
> > 
> 
> Is there a rule in R5RS that says cond can't be defined using cons?

Hygiene?

> I would expect one result of this code would be redefining cons,
> which then gets used by cond, which then calls iteslf again...

This is what's probably going on, though it better would not.

/Jerry




reply via email to

[Prev in Thread] Current Thread [Next in Thread]