1

I would like to define a function that generates lambdas, as such:

(defun my-func (FUNCTION) (lambda () (FUNCTION))) 

But when I evaluate the following

(defun my-func1 () (message "Hello World")) (funcall (my-func #'my-func1)) 

I am told that

Symbol's function definition is void: FUNCTION 
2

1 Answer 1

2

The symbol FUNCTION in your definition of my-func has a local binding for the symbol FUNCTION as variable and not as function.

So you need to call (funcall FUNCTION) in your lambda.

Furthermore, be aware that lexical binding is required for your code to work (FUNCTION must be known to the lambda outside of my-func, i.e., the lambda must actually be a closure.).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.