This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme style auto-resizing hashtable (fwd)


On Tue, Nov 03, 1998 at 11:15:53PM -0500, Jay Glascoe wrote:
> On Tue, 3 Nov 1998, Peter C. Norton wrote:
> 
> you mean you have hashes of hashes, right?
> 
> $hash_ref->{"foo"}{"bar"} = "biz";

not to mentions hashes of functions, hashes of arrays, etc.  I really only
learned about anonymous functions with scheme, but I use them to good
effect in perl.
 
> yeah, these are good too:
> 
> $thing = $array_ref->[23]{"jeep"}[7];

You can also use a more consistant syntax w/ perl and do

$thing = $ref->[23]->{jeep}->[7];

I have, over the last year, tried to cut down on the perl sugar that I
heap on in my scripts.  Eventually I don't understand what shortcut I was
relying on when something (inevitably) breaks. 
 
[snip]
> now you can peruse Jane's "stats" without going through dictionary "d".
> Best of all, any changes to "stats" will affect "d".  No hassles with
> derefrencing references, etc.

I agree with everything you say.
 
> Once ordering rears its ugly head, you lose the whole hash table O(1)
> thing.  I assume you're suggesting linking your dictionary to some sort of
> database system (like Perl's tie hash).  It seems like there's a lot of
> talk about Guile extensions supporting various databases.  I know the
> Berkeley db supports a type of ordered database.

>From reading "Scheme and the Art of Programming" (and not having finished
SICP yet), I would understand that the car of a cons cell is a pointer. 
Is suspect that guile implements cons cells this way, though I haven't
checked yet (shame on me - I'll try to puzzle out the sources one day). 
For the moment, assuming that's true, if I wanted the car of the same cons
cell to appear in 2 different lists (or in 2 different data structures -
in this case a hash and a dictionary representation of that hash) making
the car of a cons cell appear in both places should be cheap.  If this is
the case, most (all?) operations on the dictionary could be done
independanty of the hash, or through the hash, depending on which is
faster.

In short I'm just asking if a different representation could be used with
the same data to satisfy some folks' definition of a dictionary.  An
optional interface.

-- 
Peter C. Norton                      Time comes into it. / Say it.  Say it.
spacey@pobox.com                   | The Universe is made of stories,  
http://spacey.dyn.ml.org           | not of atoms. 
                                   |
                                     Muriel Rukeyser "The Speed of Darknesss"