Update 2024-03-27: Greatly expanded the "Samples" page and renamed it to "Glossary".
Update 2024-04-04: Added 5 million mid-2011 posts from the k47 post dump. Browse (mostly) them here.
Update 2024-04-07: Added ~400 October 2003 posts from 4chan.net. Browse them here.

Welcome to Oldfriend Archive, the official 4chan archive of the NSA. Hosting ~170M text-only 2003-2014 4chan posts (mostly 2006-2008).
[6 / 0 / ?]

[1395715096] Why distinguish symbols and strings?

No.958340 View ViewReplyOriginalReport
Lisps have a special data type called a "symbol." If you compare two symbols with the same name against each other with eq? the result is guaranteed to be true. This is apparently not the case with strings, at least in Scheme; two identical strings are not guaranteed to be eq?/be located in the same memory location.

Most of the more modern dynamic languages, however, use "interned" immutable strings, such that any two identical strings are guaranteed to be stored in the same memory location and thus be (the language's equivalent of) eq?.

Given this development, what is the purpose of differentiating between strings and symbols in a modern programming language? Lua programs, for instance, get by just fine using its immutable strings in much the same way that a Scheme user would use symbols. Are they practically the same thing, just stored in a different namespace, as Common Lisp stores variables and functions in separate namespaces? Is this just some historical cruft that Scheme accumulated from a time when interning immutable strings was not practical, or is there some real benefit that comes from distinguishing between the two?