5 ms·
Oops; I meant to write those in CL, but I forgot about functions having their own namespace (been playing too long in a lisp-1). It should work in CL if you us
by twilightsentry 17y ago
Oops; I meant to write those in CL, but I forgot about functions having their own namespace (been playing too long in a lisp-1). It should work in CL if you use FUNCALL.
If mquander's explanation isn't enough, you might look at it using terms from the OO world: CAR takes a pair object and calls its 'car method.
- mahmud 17y agoSo you mean a meta-circular OOP implementation, where the hosting language already has car, cdr and cons. Alright. I thought what you wrote was supposed to be a primitive implementation of the functions.
- twilightsentry 17y agoNo, not really, unless you're running the code in a metacircular interpreter. Imagine encoding the pair ('hello . 'world) into a function. You might say: (lambda (msg) (if (eq msg 'car) 'hello 'world)) You could get 'hello by applying that function to the 'car symbol, or 'world by applying it to anything else. Wrapping that in another function lets us generalise to any CAR/CDR. (lambda (car-value cdr-value) (lambda (msg) (if (eq msg 'car) car-value cdr-value)))