[slime-devel] Understanding sbcl source code
Sidney Markowitz
sidney at sidney.com
Wed Feb 4 14:43:11 UTC 2009
jcm at sdf.lonestar.org wrote, On 5/2/09 1:50 AM:
> I'm sure there's a simple answer to this question. I'm browsing the sbcl
> source to find the lowest level implementation of CAR and I found this
>
> (defun car (list) (car list))
>
> So the 'real' definition of CAR must be elsewhere. :) Perhaps in the C
> source code? Would someone point me to the correct location?
When the compiler encounters car it emits inline code. So try this in sbcl
(defun foo (x) (car x))
(disassemble #'foo)
Compare that with
(defun bar (x) (foo x))
(disassemble #'bar)
The former does not contain any function call, the latter will include a
call to the function object #'foo
So the purpose of (defun car (list) (car list)) is to define a function
object #'car after the compiler has already been taught how to compile
car inline.
More information about the slime-devel
mailing list