From: Gerald Masini
Subject: Redefining functions in KCL
Date: 
Message-ID: <904@loria.crin.fr>
I'm beginning with Common Lisp and more precisely KCL (version 
June, 3 1987).
I would like to redefine an existing function, foo for instance:

(defun foo ()
  (format nil "Old foo"))

so as the new function foo performs the same operations as the old one
plus some extra new operations. In the real case, foo is a compiled
function and its source code is not available.
So I've replaced the definition of a specially defined function, bar, by
the definition of foo, and then I've redefined the function foo:

--------------------------------------------------
(defun bar (x))

(setf (symbol-function 'bar) (function foo))

(defun foo ()
 (format nil "New foo")
 (funcall (function bar)))

(function foo)
(function bar)

(foo)
(bar)
--------------------------------------------------

When I load the preceding file, I get this:

>(load "foo.lsp" :print t)
Loading foo.lsp
BAR
(LAMBDA-BLOCK FOO () (FORMAT NIL "Old foo"))
FOO
(LAMBDA-BLOCK FOO () (FORMAT NIL "New foo") (FUNCALL #'BAR))
(LAMBDA-BLOCK FOO () (FORMAT NIL "Old foo"))
"Old foo"
"Old foo"
Finished loading foo.lsp
T

Anyone to explain me what happens and how to solve my problem?
MTIA,