3 ms·
You are actually in violent agreement with the parent. The grandparent poster was confused why the syntax (foo (1 2)) can be used to apply FOO to (1 2). As the
by asdlllkasdasd 9y ago
You are actually in violent agreement with the parent.
The grandparent poster was confused why the syntax (foo (1 2)) can be used to apply FOO to (1 2). As the parent points out, for typical Lisps this would actually give an error; instead, (foo '(1 2)) would be the appropriate syntax to apply FOO to the form (1 2). Indeed, when strictly evaluating (foo '(1 2)), first the arguments are evaluated. Since functions self-evaluate, FOO evaluates to itself, while '(1 2) evaluates to (1 2). Then, FOO is applied to (1 2). This is in complete agreement with what you said and what the specification says.
However, the Lisp interpreter at hand actually self-evaluates lists whose head is not a function. Thus (1 2) self-evaluates and (foo (1 2)) has the same effect as (foo '(1 2)).
- aktau 9y agoFantastic comment, this cleared up one or two headscratchers I encountered while patterning a Lisp I was writing in Lua with LPeg (I had just encountered LPeg and wanted to do something fun with it) on Peter Norvig's Lis.py. It didn't 100% square with what I recalled from other Lisps.
- lispm 9y ago> Since functions self-evaluate, FOO evaluates to itself No, in Lisp FOO is a name of a function, not a function itself. Thus FOO evaluates to a function (otherwise it would be an error) in a Lisp-1 like Scheme. In a Lisp-2 like Common Lisp, one would say that the function value of FOO is retrieved. > Indeed, when strictly evaluating (foo '(1 2)), first the arguments are evaluated Actually not. In Lisp the first item needs to be looked at first. If it is determined to name a function, then we can evaluate the arguments, of which there is only one in this case.
- asdlllkasdasd 9y agoYou are right about both points! PS: The second you quoted out of order. If you reread, you will see that I was referring to FOO as the first "argument" (a typo for "element"..).