Re: Hash



Jon Harrop wrote:

.... snip ...

There isn't much point in allowing duplicate key-value pairs.
Allowing the same key to map onto different values can be useful
(e.g. to implement scope in an interpreter), as OCaml's built-in
hash table does.

hashlib [1] was designed with scoped symbol tables in mind. To use
it for such you would need openscope and closescope functions,
together with a linked list of scopes. Openscope would extend the
list after creating a new hashtable for that scope, and closescope
would destroy the table and remove the last entry in the list.
Then searching for an identifier is simply searching each table
starting at list end. (A reversed list would be handy for this.)
New entries always go into the current scope, which is at the list
end. An entry count field will enable detection of multiple
definitions in a single scope (or other flags can be used). The
auxiliary functions customizing the tables would be common to all.

That would make the symbol table search O(N), where N is the count
of scopes active. It will normally be O(1) because most entries to
be used will be in the current scope. Table entry would be O(1).
A further identical table can be used to hold the reserved words,
which is searched to classify an identifier as being reserved or
available.

[1] <http://cbfalconer.home.att.net/download/>

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>


.



Relevant Pages

  • Re: Which scope is searcheg first ?
    ... > 4.Current namespace data ... searching starts at the most local scope and progresses ... outward to the least local scope. ... Templates also have some oddities because searching ...
    (comp.lang.cpp)
  • Re: JSTL problem
    ... Unless you have an explicit need for another scope, I think that the request attribute will fill your needs. ... not....if it fails ... specified in the JSP. ... I don't know what the specific order is for searching the scopes. ...
    (comp.lang.java.programmer)
  • Search not working on custom templates?
    ... I've created a site from a custom site template in SharePoint 2.0. ... through the process of creating a content index and scope on this site. ... no matter what I'm searching for. ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Sending hex number as is
    ... > searching the archive. ... Or investigate the struct and/or pickle modules. ... depending on the broader scope of what ...
    (comp.lang.python)
  • Pistol Scope
    ... hunting with a handgun so I'm now searching for a simple scope. ... They have a Simmons Pro Hunter for pistols. ...
    (rec.hunting)