reduced size symbols/keywords
- From: verec <verec@xxxxxxx>
- Date: Fri, 29 Aug 2008 06:39:14 +0100
Toying, toying ... rather than doing useful work ... (Kenny must be
right after all :-)
Out of sheer curiosity (rather than need) I'm wondering if there
is a way to reduce the size (memory footprint) of symbols.
CL-USER 11 > (describe 'keyword)
keyword is a symbol
name "KEYWORD"
value #<unbound value>
function #<unbound function>
plist (type::direct-type-predicate keywordp)
package #<The COMMON-LISP package, 3/4 internal, 978/1024 external>
Here I'm counting five slots, for a (32 bit machine) total size
of 20 bytes, just for the structure, when the actual "payload"
is only 12 bytes, or about 60% "waste"
So, I'm wondering if there's an (entirely portable) way to define
"trimmed down" symbols that would exhibit much less overhead.
Obviously, I thought that keywords must be that trimmed down version
of symbols ... except they are not:
CL-USER 12 > (describe :keyword)
:keyword is a symbol
name "KEYWORD"
value :keyword
function #<unbound function>
plist nil
package #<The KEYWORD package, 0/4 internal, 5196/8192 external>
This question is not (entirely) rhetoric, as I'm thinking of some
application reading 1,000,000s words out of text files and turning them
into symbols/keywords for processing. Cutting down the memory
footprint by half or more would be extremely significant, while still
preserving "most" of the properties of symbols, while sacrifing a few,
ie, while
CL-USER 15 > (setf (symbol-function :cons) #'cons)
Error: Defining function :cons visible from package KEYWORD.
1 (continue) Redefine it anyway.
2 (abort) Return to level 0.
3 Return to top loop level 0.
Type :b for backtrace, :c <option number> to proceed, or :? for other options
CL-USER 16 : 1 > :c 1
#<Function ((compiler::def-nil-function cons) . cons) 204AD802>
CL-USER 17 > (:cons 1 2)
(1 . 2)
is cute, I'm ok with those new keywords/symbols to forego everything (function, plist, package) but the value slot.
How would I go about
(defun/defmacro word (..) ... )
such that
(word 'some-word)
and
CL-USER 19 > (describe 'some-word)
some-word is a symbol
name "SOME-WORD"
And that's it?
Many Thanks
--
JFB
.
- Follow-Ups:
- Re: reduced size symbols/keywords
- From: Alex Mizrahi
- Re: reduced size symbols/keywords
- From: Kenny
- Re: reduced size symbols/keywords
- From: Rainer Joswig
- Re: reduced size symbols/keywords
- From: John Thingstad
- Re: reduced size symbols/keywords
- Prev by Date: Re: What do you LISPers think of Haskell?
- Next by Date: Re: Gene Expression Programming(GEP)
- Previous by thread: Re: Is READ-LINE required to return a fresh string?
- Next by thread: Re: reduced size symbols/keywords
- Index(es):