Related articles |
---|
Hash specifics degroot@cpsc.ucalgary.ca (1990-12-11) |
Re: Hash specifics johnl@iecc.cambridge.ma.us (1990-12-11) |
Re: Hash specifics chased@Eng.Sun.COM (1990-12-11) |
Re: Hash specifics pardo@cs.washington.edu (1990-12-11) |
Re: Hash specifics henry@zoo.toronto.edu (1990-12-12) |
Re: Hash specifics baxter@zola.ICS.UCI.EDU (Ira Baxter) (1990-12-13) |
Re: Hash specifics lupine!rfg@uunet.UU.NET (1990-12-13) |
Re: Hash specifics rfg@ncd.com (1990-12-13) |
Re: Hash specifics rfg@ncd.com (1990-12-13) |
Re: Hash specifics bart@cs.uoregon.edu (1990-12-13) |
Re: Hash specifics roth@resi.rice.edu (1990-12-14) |
Re: Hash specifics oz@nexus.yorku.ca (1990-12-14) |
[6 later articles] |
Newsgroups: | comp.compilers |
From: | Ira Baxter <baxter@zola.ICS.UCI.EDU> |
Keywords: | design |
Organization: | Compilers Central |
References: | <1990Dec12.221425.569@zoo.toronto.edu> |
Date: | 13 Dec 90 05:07:17 GMT |
In <1990Dec12.221425.569@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
>Actually, I have never figured out why people seem so obsessed with perfect
>hashing, since the hash functions typically seem noticeably expensive, and
>it has always seemed to me that a fast hashing function plus fast resolution
>of occasional collisions would be easier and just as good.
As far as I can tell, perfect hashing costs extra.
If you have a lexer independent of the parsing mechanism, so that it
hasn't got any idea whether the next string is a keyword or not
(assemblers scanning the opcode field violate this requirement), then
you'll have to do a symbol/string table probe anyway, which can't be done
using a perfect hash. So why not put the keywords into the string table
with a tag bit noting they are keywords? The lexer now collects a
word-atom, and looks it up; if tagged, it reports the corresponding
keyword, if not, it reports a user symbol. This scheme saves the
*additional* cost of doing a perfect hash.
--
Ira Baxter
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.