[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

replies to hash table comments

To JonL:  Yes, *PRINT-HASH* would be a switch analogous to *PRINT-ARRAY*.
  If T, then the contents of the hash table would be displayed.  If NIL, then
  the current #<HASH-TABLE ...> notation would be used.  The initial value of
  the switch would be implementation-dependent.

To Mlynarik:  I'm not thrilled with the idea of generalizing #S to objects
  other than defstructs, but I guess that's a matter of personal taste.
  By the way, Symbolics writes pathnames as #P"/usr/dst/foo.bar".

To Moon:  there are three reasons why DESCRIBE doesn't solve the problems
that arise in teaching beginners about hash tables:

  1. In some implementations, DESCRIBE does not show the contents of a
     hash table.  CMU Common Lisp currently displays this regrettable (but
     legal) behavior.

  2. It is a hassle for a beginner to have to type (describe my-table)
     every time he wants to see what's inside his hash table.  And if
     he's passing the hash table as an argument to a function, it would
     be nice if its contents could be displayed automatically by TRACE
     or by the debugger simply by setting *PRINT-HASH* to T.  This kind
     of behavior would make hash tables a first class "visible" data
     structure, as easy to understand as lists and vectors.

  3. The proposed #H notation would make it possible to read and write
     hash tables from files, and to create them interactively with a single
     expression rather than doing a MAKE-HASH-TABLE and a bunch of SETF's.

To recap, the proposal was that if *PRINT-HASH* was T, then hash tables would
be displayed as #nH(type (key1 . value1) (key2 . value2) ...)  where "n" was
the size of the table and "type" was one of EQ, EQL, or EQUAL.  When reading a
#H expression it should be possible to omit the numeric argument, in which case
the system will pick some reasonable size based on the number of key/value
pairs supplied.  It should also be possible to omit the type, in which case EQL
is assumed.

So #H((FOO . 37) (BAR . 42)) might print as #20H(EQL (FOO . 37) (BAR . 42)).

-- Dave