user3043278
user3043278

Reputation: 184

Lisp redefining functions

Can someone help understand what is happenning here?

(DEFUN G(L)(+(CAR L)(CADR L)))
(SETQ H`F)(SET H `G)

I want to know what happends when I evaluate (F` (2 3 4 5 6 ))

I've written it in my lisp interpreter but I get the following error:

Undefined function F

Upvotes: 0

Views: 189

Answers (1)

Rainer Joswig
Rainer Joswig

Reputation: 139261

Common Lisp has a namespace for values and another namespace for functions.

CL-USER 49 > (DEFUN G(L)(+(CAR L)(CADR L)))
G

CL-USER 50 > (SETQ H 'F)
F

CL-USER 51 > (SET H 'G)
G

CL-USER 52 > F
G

CL-USER 53 > (symbol-value 'F)
G

CL-USER 54 > (symbol-function 'f)

Error: Undefined function F in form (SYMBOL-FUNCTION F).

All you did was setting the value of F, but not the function F.

Upvotes: 5

Related Questions