8
votes

In Common Lisp, there are obviously some special characters that act as shortcuts for certain forms. 'x means (quote x). #'f means (function f). I had thought those (as well as backtick) were the only ones, but then I learned about #(), which is apparently a vector, and just today someone mentioned #., which apparently does something with evaluation time.

Try as I might, I can't seem to find a comprehensive list of which prefix symbols mean something and what they do? Is this something that's left to the implementation to decide, or could someone point me to somewhere in the standard that lists these shortcuts comprehensively?

2
There's only a comprehensive list in the standard, but you can define new macro characters at any time. - Joshua Taylor
Well that's news to me. What's the name of the call I need to make to define my own? - Silvio Mayolo
I'm putting together an answer, but start by having a look at Chapter 17 Read Macros from On Lisp. You may also find my answer to How to define symbols that will work like ( and ) by symbol macro? helpful. - Joshua Taylor
Sidenote: #. works at reading time. - monoid

2 Answers

9
votes

The HyperSpec, in 2.4 Standard Macro Characters, enumerates "the macro characters defined initially in a conforming implementation". You can define your own using set-macro-character, which handles the types like ' which have no "prefix" to them, and set-dispatch-macro-character, which handles the type that are prefixed by a dispatch character (typically #).

In addition to the HyperSpec, you may find Chapter 17, Read Macros from Paul Graham's On Lisp helpful. It begins with an implementation of ', i.e., the macro character that expands to (quote ...). Answers to How to define symbols that will work like ( and ) by symbol macro? are also helpful, as there are some uses of set-macro-character.

5
votes

What you are looking for are Standard Macro Characters.

You can define your own using set-dispatch-macro-character and set-macro-character.

In fact, this is how I implemented XML Parsing.