Keyword abuse (Re: reduced size symbols/keywords)
- From: Marco Antoniotti <marcoxa@xxxxxxxxx>
- Date: Fri, 29 Aug 2008 07:01:09 -0700 (PDT)
On Aug 29, 4:15 pm, Tim Bradshaw <tfb+goo...@xxxxxxxx> wrote:
On Aug 29, 6:39 am, verec <ve...@xxxxxxx> wrote:
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
The thing you are looking for is a string. You want to have only one
instance of each string: that's what a hashtable does.
If you want your lexer to avoid consing even temporary instances of
the strings it reads, then you probably want to use a trie (unlike the
above two you will have to write your own of these). Generally it is
probably not worth the effort though, unless you have other reasons to
want to use a trie - the ephemeral string consing will be pretty
cheap.
It is true that Neanderthal Lisp programs did use symbols for strings
a lot, but I don't think people would generally do that now (outside
of AI depts, where most of the Lisp programmers are still pretty
neanderthal).
Apart from all the previous comments which I agree with, there is an
issue that has been nagging me for some time. I see several libraries
(I won't name names!) that "abuse" keywords. The typical example is
the home brew HTML replacement that does the following
(:html (:head ...) (:body (:h1 ... (:ul ...))))
you get the idea.
I would advocate against this (and similar) use of keywords. Packaged
symbols are perfect for this kind of job.
Cheers
--
Marco
.
- Follow-Ups:
- Re: Keyword abuse (Re: reduced size symbols/keywords)
- From: John Thingstad
- Re: Keyword abuse (Re: reduced size symbols/keywords)
- References:
- reduced size symbols/keywords
- From: verec
- reduced size symbols/keywords
- Prev by Date: Re: reduced size symbols/keywords
- Next by Date: Re: Keyword abuse (Re: reduced size symbols/keywords)
- Previous by thread: Re: reduced size symbols/keywords
- Next by thread: Re: Keyword abuse (Re: reduced size symbols/keywords)
- Index(es):
Relevant Pages
|