[R6RS] Table proposal

Matthew Flatt mflatt
Mon Apr 25 16:39:45 EDT 2005

At Mon, 25 Apr 2005 15:27:52 -0400, Marc Feeley wrote:
> As you may have noticed, a hash table SRFI (SRFI-69) has just been
> announced.  In many ways it is similar to my proposal, in other
> ways it is different.  I'd like to comment on SRFI-69, but only
> after there has been some discussion of the table proposal by the
> committee.  So please take a minute to read my table proposal and
> comment on it.  I'd like to know if you are generally favorable
> or not.

Both are fine drafts to me. I have a slight bias in favor of the SRFI
version, but it's nothing to do with the content --- only that we
should take advantage of the SRFI process whenever it's reasonable.

I have one suggestion, which is the same for both proposals: instead of
a default value for for `table-ref', accept a thunk that is tail-called
when the key is not found, and make the default thunk report an error.

In quick scripts where `table-ref' is used with the assumption that it
will find a value, getting a "no value for X in table" error is usually
more helpful than an "expected Y but got #f" error.

In not-so-quick programs, the usual benefits of failure thunks apply.

The trade-off is that the programmer has to write `(lambda () #f)' to
make #f the default result, and #f is often an appropriate failure
result. I find this trade-off worthwhile.

(My best student this semester wants to know why `assoc' doesn't take a
failure thunk. :)


More information about the R6RS mailing list