On Wed, Aug 1, 2012 at 3:56 PM, David Herman <[email protected]> wrote:
> In the Lisp world, strings and symbols are isomorphic, but there's a sense
> that symbols have identity where strings don't. Now, Lisp symbols are
> historically forgeable and interned, so this isn't exactly the same concept.
In Common Lisp (which I am most familiar with, and I think is a
relevant design), this is not right.
A symbol is an object; it has a name property, which is a string. The
name need not be unique. Package (namespace) objects are mappings
between strings and symbols, with the constraint that if a symbol is
in a package, then the symbol's name property is also the string that
the package maps to it. (This constraint can be considered a mistake,
in that it prohibits renamed imports.)
Therefore, a symbol which is not in a package ("uninterned") is not
"forgeable" — that is, you cannot obtain it starting from its name
unless it's in some other table you have — with the caveat that since
CL is very far from a capability design, there are plenty of ways to
get your hands on a symbol being used, so this does not have any
security properties.
Uninterned symbols are used for unique generated names ("gensyms");
interned symbols (those which exist in packages) are used for names
written in source code. These essentially correspond to the use cases
of the proposed unique-names and strings, respectively; CL's design
gains orthogonality by having even "ordinary names" be symbols rather
than strings, so the programmer need not have different code paths.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss