lfkdsk / lfkdsk.github.io

2 stars 2 forks source link

Symbol #4

Open lfkdsk opened 6 years ago

lfkdsk commented 6 years ago

A symbol is an object with a simple string representation that (by default) is guaranteed to be interned; i.e., any two symbols that are written the same are the same object in memory (reference equality).

Why do Lisps have symbols? Well, it's largely an artifact of the fact that Lisps embed their own syntax as a data type of the language. Compilers and interpreters use symbols to represent identifiers in a program; since Lisp allows you to represent a program's syntax as data, it provides symbols because they're part of the representation.

What are they useful apart from that? Well, a few things: