Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common Lisp Special Shortcut Characters

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?

like image 933
Silvio Mayolo Avatar asked Jan 15 '15 21:01

Silvio Mayolo


People also ask

What are Lisp symbols?

A Lisp symbol is a data object that has three user-visible components: The property list is a list that effectively provides each symbol with many modifiable named components. The print name must be a string, which is the sequence of characters used to identify the symbol.

Does Common Lisp have types?

Common Lisp has a complete and flexible type system and corresponding tools to inspect, check and manipulate types. It allows creating custom types, adding type declarations to variables and functions and thus to get compile-time warnings and errors.

What is a special form in programming?

A special form is a primitive function specially marked so that its arguments are not all evaluated. Most special forms define control structures or perform variable bindings—things which functions cannot do. Each special form has its own rules for which arguments are evaluated and which are used without evaluation.

Does Lisp have state?

SPC k opens the lisp state menu, providing commands for structural editing with Smartparens. Any command will put the current buffer into lisp state, a transient state where you can use single character keybindings for the commands (no need to use SPC k each time).


1 Answers

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.

like image 90
Joshua Taylor Avatar answered Sep 20 '22 15:09

Joshua Taylor