1

Why is this an error in SBCL? How do you call a lambda passed to your function?

* (defun call-foo (foo) (foo))
; in: DEFUN CALL-FOO
;     (SB-INT:NAMED-LAMBDA CALL-FOO
;         (FOO)
;       (BLOCK CALL-FOO (FOO)))
;
; caught STYLE-WARNING:
;   The variable FOO is defined but never used.

; in: DEFUN CALL-FOO
;     (FOO)
;
; caught STYLE-WARNING:
;   undefined function: FOO
;
; compilation unit finished
;   Undefined function:
;     FOO
;   caught 2 STYLE-WARNING conditions

CALL-FOO
user541686
  • 205,094
  • 128
  • 528
  • 886

1 Answers1

3

This is an introduction to Common Lisp: http://www.cs.cmu.edu/~dst/LispBook/

You might also want to read about FUNCALL.

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
  • +1 thanks for mentioning `funcall`. Does that mean `funcall` doesn't do static type-checking? (Is there any way to call lambdas while ensuring static type checking?) – user541686 Aug 03 '13 at 19:33
  • 3
    @mehrdad: funcall is a function. 'functions' don't do 'static type checking'. A compiler might. But then you need to tell the compiler something about types. Are you sure you want to use Lisp? – Rainer Joswig Aug 03 '13 at 19:41
  • Well, what introduced me to SBCL was [this answer](http://stackoverflow.com/questions/18031009), but it seems like it doesn't work the way I expected. Thanks for the info. – user541686 Aug 03 '13 at 20:28
  • 1
    @Mehrdad, SBCL, like any [Common Lisp](https://en.wikipedia.org/wiki/Common_Lisp) compiler, must follow the [Common Lisp standard](http://www.lispworks.com/documentation/HyperSpec/Front/), and by this standard you must use *[funcall](http://www.lispworks.com/documentation/HyperSpec/Body/f_funcal.htm)* when you pass a function as argument. Before looking for extra compiler features, such as type inference (which is not mandatory in the standard, nor even mentioned I believe), you may consider first learning the language. –  Aug 04 '13 at 22:45