4 ms·
Title should be "Perceived problems with hash-tables in Common Lisp"... It's true that it would be interesting to have native syntax for hash-tables so you cou
by Hexstream 18y ago
Title should be "Perceived problems with hash-tables in Common Lisp"...
It's true that it would be interesting to have native syntax for hash-tables so you could read and dump them like you can lists and arrays and other stuff. Surprisingly the article doesn't even mention that which is the only real problem with CL's hashtables, aside from the inability to define arbitrary lookup mechanisms beyond eq, eql, equal and equalp...
- silentbicycle 18y agoHaving such a cumbersome syntax for hash tables is just as real a problem as the verbosity some Lisp programmers hold against e.g. Java. One solution could be a read macro that translates into the (setf (gethash ...)) form. Lisp read macros are usually prefix, though, and [key]hash is awkward. OTOH, adding suffix read macros (maybe only of the form symbol[... values], e.g. hash[# key] or hash[: key], with brackets and char(s) at the beginning to represent which suffix read macro. Or, making the hash a function: (hashname key) to get, (hashname key newval) to set.
- jrockway 18y ago> Title should be "Perceived problems with hash-tables in Common Lisp"... Good idea. Title changed :) I decided not to bring up the printed representation, since other languages don't do much better. Perl will print either the keys and values with no spaces between them (by default), or something like "5/8" in scalar context, or "HASH(0x123456)" if it's a reference. No better than CL, and nobody complains about this :)