lispm•

First you need to see what the reader creates:

CL-USER 24 > '(let (#'42) (+ . #'5))
(LET ((FUNCTION 42)) (+ FUNCTION 5))

or

CL-USER 25 > (read-from-string "(let (#'42) (+ . #'5))")
(LET ((FUNCTION 42)) (+ FUNCTION 5))

Does that help?

#' and . are already doing something during parsing by the reader - see above.

Note though, that this is a rather useless 'tip' - one should not use this LET + #' effect in code. This use of the dot-notation is sometimes, seen, though.

8
easysolutionsOP•

Ok, I got it. I thought #'x calls x, didn't realize it expands to (function x). Thanks.

1
commonslip•

It is better to think of #'x as being read as (function x) instead of expanding to (function x). In Common Lisp, whose reader is a pretty complicated thing, it is good to start remembering that there is a distinct phase reading before macroexpansion or other evaluation takes place.

2
easysolutionsOP•

Great point. Thanks.

1
xach•

It may help to understand that the reader expands reader-macros like #' and ' even when they are not in places that are evaluated for a value.

5
easysolutionsOP•

Ok, I got it. I thought #'x calls x, didn't realize it expands to (function x). Thanks.

2
Grue•

It expands to

(let ((function 42)) ...)

Figure the rest yourself.

1
easysolutionsOP•

Trying (function 42), gives me "FUNCTION: 42 is not a function name; try using a symbol instead". I know that #' is for functions. Looking at the hyperspec, this:
http://www.lispworks.com/documentation/HyperSpec/Body/t_fn.htm

kind of seems like it is what is happening/being used(?), but I don't understand what is going on.

1
Grue•

It doesn't matter what FUNCTION does, start with LET. LET creates a binding for FUNCTION, so that it evaluates to 42 inside of this LET.

#'aaa is a reader macro that expands to (function aaa)

(something . (foo bar)) is the same as (something foo bar), because of how lists are constructed from cons cells.

2
easysolutionsOP•

Aha. I thought #'x calls x, didn't realize it expands to (function x). Ok, I got it. Thanks :-)

..Heh, rereading my reply, you actually specifically said that it expands to (let ((function 42)) ... ,but because of my above misconception, I was totally blind of the existance of let, and was seeing "call 42" instead of "we now have this symbol called 'function' here.

1
spacebat•

The let assigns the value of 42 to the symbol 'function'. Is there something you don't get in the excellent explanation in the blog comments?

1
[deleted]•

[deleted]

1