CL is Lisp-2, therefore it doesn't produce the same thing - a function which can be called normally.
- Code: Select all
* (lisp-implementation-type)
"SBCL"
* (lisp-implementation-version)
"1.0.56.0.debian"
* (defvar f nil)
F
* (boundp 'f)
T
* (fboundp 'f)
NIL
* (setf f #'(lambda (x) (expt x 2)))
#<FUNCTION (LAMBDA (X)) {BF7DD1D}>
* (boundp 'f)
T
* (fboundp 'f)
NIL
* (funcall f 3)
9
* (f 3)
; in: F 3
; (F 3)
;
; caught STYLE-WARNING:
; undefined function: F
;
; compilation unit finished
; Undefined function:
; F
; caught 1 STYLE-WARNING condition
debugger invoked on a UNDEFINED-FUNCTION in thread
#<THREAD "initial thread" RUNNING {AB19829}>:
The function COMMON-LISP-USER::F is undefined.
* (setf (symbol-function 'f) #'(lambda (x) (expt x 3)))
#<FUNCTION (LAMBDA (X)) {BFAD1BD}>
* (f 3)
27
* (funcall f 3)
9
* (fboundp 'f)
T
* (dribble)
As you can see the symbol must be
fbound, so that it can be used in a first position of list. If the function is saved as a value of variable denoted by that symbol, you can call it via
funcall.