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

Re: hash-table-for-each parameter order



On Apr 26, 2005, at 5:30 PM, Ken Dickey wrote:

Procedure: hash-table-for-each hash-table proc

Tradtionally, one uses a table as the 1st parameter to functions manipulating
tables.

But tradtionally, for-each takes a proc and a collection
 (for-each proc list ...).

I would recommend using another name, perhaps
  table-walk table proc  ;; or hash-table-walk
or
  hash-table-for-each proc table

As the intent is clearly to treat the table as a collection.

Please don't confuse me on parameter order. I get confused easily enough on
my own.  8^)

Cheers,
-KenD

I agree.  The procedure parameter should come first and
be consistent with for-each.  I feel this is more consistent,
and also it allows future extensions of the interface to
multiple tables, i.e.

    (hash-table-for-each proc table1 table2...)

The semantics could be to apply proc for each key that is
contained in all tables (error or not if some key does not exist
in all tables), or to apply proc for each key that appears in
table1 and it is an error if a key in table1 does not exist
in the other tables.  I'm not suggesting that multiple tables
be supported by SRFI-69, but please make the interface extensible
for allowing this in the future (or as an implementation specific
extension).

Marc