Why does Lisp allow you to create random atoms?

I know that atoms are symbols for things such as nil, t, etc. but why would it let you create random new ones? You could do this

(print 'Hello-World)

and it would be valid. almost every other programming language doesn't let you do this.

I'm not sure why you think the behavior should be different, so I'm groping in this answer; I hope it helps.

The main purpose of symbols is to serve as the name of a variable. In any old programming language, when you say   x=3   x is a symbol. Perhaps what's confusing you is that t and nil name constants, and that's more like the non-programming meaning of "symbol" as representing a particular thing. But variable names also represent a particular thing, namely the address in memory of the variable. So even if you change the value of x, it's still the same variable.

They're called "atoms" just because you're not supposed to dissect them into letters -- they're indivisible. So, numbers are atoms, too. But strings aren't, and lists aren't. It's the symbol itself that's atomic, not the value of the variable it represents, which could of course be a list.

1 Like