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

Re: Issue: TAIL-RECURSION-OPTIMIZATION (Version 2)



> That's not true, because a function can't reference -itself-, it can
> only reference -its name-.  For example,
> 
> (defun foo (x)
>   (if (zerop x) 1 (* x (foo (1- x)))))
> (setf (symbol-function 'bar) (symbol-function 'foo))
> (defun foo (x)
>   (* x 2))
> (bar 3) => 12, not 6

Good point; this example helps clarify the issue:  is this the behavior
desired?  I think not, since when the programmer wrote the DEFUN for FOO
he most likely intended that the call to FOO referred to the function
he was defining, not to some other FOO that might be defined later.
Thus, in this case, early binding would cause less surprise than late
binding.