Subject: Re: Q: on hashes and counting
From: Erik Naggum <>
Date: 2000/10/19
Newsgroups: comp.lang.lisp
Message-ID: <>

* Peter Vaneynde <>
| Erik Naggum <> writes:
| > * The Glauber <>
| >   Here's my cut at that task:
| > 
| > (let ((hash (make-hash-table :test #'equal)))
| >   (with-open-file (stream ...file-args...)
| >     (handler-case
| > 	(loop
| > 	  (let ((vendor (read-sequence stream (make-string 5))))
|                                        (make-string 5) stream
| not?

  Huh?  Oh, the argument order.  Please be a little more verbose.  I
  have no idea how that got in there.

| hash-table-keys is not in the ANSI-spec, nor in ACL5. I guess it's a
| new feature of ACL6?

  Oops, sorry, it's my own, an internal function that knows how the
  hash-table is laid out and does a quick scan through the keys vector
  to collect keys.

| I suppose it's quite a bit faster then:
| (loop for key being the hash-keys in hash collect key)
| ?

  That's exactly what I would suggest for the portable definition.

  The internal function is twice as fast as this loop.

| >   Did you compile the Lisp code?  Perl _always_ runs slower than Lisp
| >   for me.  Of course, I don't use a (good) toy Lisp like CLISP, but
| >   Allegro CL, and I generally compile with high optimization
| >   settings.
| Your solution outruns the Lisp one on this old SPARC here... 

  I hope you meant "Perl", but couldn't bring yourself to type it.  :)

| >   I have a situation not dissimilar to yours, where I have ticker
| >   codes for various financial instruments, and I found that it paid
| >   off handsomely to use symbols.  Some "modern" Lisp books tell us not
| Symbols in hash-tables or using the plists of the symbols? (I'm
| supposing you want to store more then one property per symbol of
| course)

  I let the value slot of the symbols hold one of a variety of
  objects, according to the type of the financial instrument.

  I don't use symbols as the keys in hash-tables, I use strings, but
  that's just an accident of history rather than a conscious decision.

| >   I agree with everything you say, but I would
| >   attack to death your right to say it.
| > 				-- Tom Stoppard
| I've been dying to ask in what context this was said...

  :)  Actually, I have no idea.  Mark Morford picked this one for the
  SF Gate Morning Fix one day.  I found it hilarious.  (He also uses
  "If this is not what you expected, please alter your expectations"
  in the disclaimer of the Morning Fix, but someone objected so
  strongly to my using that as a .signature, I found it worthwhile to
  pick another one.)

  I agree with everything you say, but I would
  attack to death your right to say it.
				-- Tom Stoppard