On Dec 3, 2010, at 9:33 AM, David Steiner 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?
Chicken defines 'caar' and the other routines in terms of direct
references rather than thru the current bindings. So 'caar' is not
'(lambda (x) (car (car x)))' but something much more specific to the
implementation.
In general it is not possible to just redefine a few primitives and run
arbitrary programs with the expectation of success. One must redefine
those routines used by the program.
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users
Best Wishes,
Kon
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users