From: Tim Bradshaw on
On 2010-05-14 05:00:36 +0100, George Neuner said:

> Symbols are a heavyweight structure: they contain a name reference, a
> function slot, a value slot, a property list, and a package reference
> - at least 40 bytes (64-bit) plus a header if the implementation uses
> headers.

Symbols don't actually need to contain these slots - for instance an
implementation could have very lightweight symbols whose "slots" were
actually obtained by having hashtables keyed on some unique property of
the symbol (this probably has to be something like address I think,
because names do not need to be unique - (eq (make-symbol "FOO")
(make-symbol "FOO")) is false.

So uninterned symbols with no slots used could be quite small - maybe
two or three words + storage for the name (which would dominate the
space).

I wonder if any implementations have done this? I suspect not.

From: Rob Warnock on
Tim Bradshaw <tfb(a)tfeb.org> wrote:
+---------------
| George Neuner said:
| > Symbols are a heavyweight structure: they contain a name reference, a
| > function slot, a value slot, a property list, and a package reference
| > - at least 40 bytes (64-bit) plus a header if the implementation uses
| > headers.
|
| Symbols don't actually need to contain these slots - for instance an
| implementation could have very lightweight symbols whose "slots" were
| actually obtained by having hashtables keyed on some unique property of
| the symbol ...
+---------------

Yup.

+---------------
| I wonder if any implementations have done this? I suspect not.
+---------------

Well, I know of one that at least *partially* does it... ;-} ;-}

CMUCL has no SYMBOL-FUNCTION slot in its symbols, only -VALUE, -PLIST,
-NAME, & -PACKAGE. [And a non-standard HASH slot, used only internally.]
SYMBOL-FUNCTION is actually implemented as a call to the CMUCL-idiosyncratic
internal "info" database:

cmu> (info function definition '+)

#<FDEFINITION object for +>
T
cmu> (kernel:fdefn-function *)

#<Function + {10112289}>
cmu> (eq * #'+)

T
cmu> (eq ** (symbol-function '+))

T
cmu>

In practice, most functions are resolved at compile time, so this path
is used mainly for FUNCALLs of non-constants which evaluate to symbols
at runtime.


-Rob

-----
Rob Warnock <rpw3(a)rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607