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

Tables returning nil if no value

Here's what I had in mind when I added tables:  I really wanted them to
be extremely minimal, with very little structure.  I wanted them to be
as simple and primitive as pairs.  They were to be viewed as primitive
components out of which one could build higher-level abstractions.  My
inspiration was SNOBOL4's tables.  I didn't like the idea of having a
zillion bells and whistles like in Common Lisp, or worse, Zetalisp.  It
was always my intent that the tables created by MAKE-TABLE would be weak
tables, and they clearly could be; that's why there's no TABLE-WALK.  I
never got around to implementing them that way, however.

I'm not saying this is the best way for this feature to be, I'm just
saying it's what I had in mind.

The correct way to deal with lookup failure is NOT to return a second
found? value, but instead to either build failure into the language (as
in Prolog, Snobol, or Icon, or zetalisp's condition system), or to pass
multiple continuations (like PDP-10 assembly language programmers do):

  (table-entry table key
	       (lambda (val) ... success ...)
	       (lambda () ... failure ...))

Given that neither of these alternatives seems particularly realistic
(the first because it's too drastic and the second because it's just as
cumbersome as dealing with multiple values), I think the way it is is