Common Lisp Hash-Dot #. Reader Macro
Asked Answered
P

1

5

Recently, I have come across the so-called hash-dot Common Lisp reader macro and am wondering how it works and what it does. Using search engines was not of much help, so any examples, explanations and especially uses-cases are most welcome.

Ptomaine answered 14/2, 2018 at 18:9 Comment(1)
lispworks.com/documentation/HyperSpec/Body/02_dhf.htmMussorgsky
P
9

In the spec this is called sharpsign dot. It does read-time evaluation. You can search the Common Lisp hyper spec for that. I don’t have it to hand but I believe in Emacs with slime one can look up the documentation for reader macros. Do C-c C-d C-h to see if there is a command for that.

#.foo reads as whatever (eval foo) returns. Thus:

CL-USER> '((+ 1 2) #.(+ 1 2))
((+ 1 2) 3)
CL-USER> (read)
#.(* 3 4)
12
Playground answered 14/2, 2018 at 18:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.