1

I have define a function.

(defun my-func (v0)
  (lambda (v1)
    (+ v0 v1)))

Then input the expression in the slime command line.

((my-func 1) 5)

Then the sbcl report "illegal function call".I don't know why it is illegal. In my opinion, (my-func 1) returns a lambda function, then apply the lambda function to the number 5.Is my opinion wrong? I'm a beginner to learn the common lisp.

sunhang
  • 367
  • 2
  • 11
  • 2
    The evaluation rules of Common Lisp (http://www.lispworks.com/documentation/HyperSpec/Body/03_abab.htm) say that the first element is not evaluated, only the arguments. That means that you cannot put a function that is built at runtime in the function place. In order to call functions computed at runtime, you need to use FUNCALL: http://clhs.lisp.se/Body/f_funcal.htm. Also, this question is a duplicate (https://stackoverflow.com/search?q=illegal+function+%5Bcommon-lisp%5D) – coredump Feb 07 '17 at 07:16
  • Even being a duplicate, this question is asked in a clearer manner than all others. And the answer is simple and straightforward too. I'd have upvoted it if I'd could. – Mathias Dolidon Jan 20 '18 at 19:40

0 Answers0