[plt-scheme] likely 3.99.0.22 -> 3.99.0.23 incompatibility: hash tables
While we're cleaning up the language in v4, we'd like to do something
about the API for using hash tables:
* The names `hash-table-get' and `hash-table-put!' are long enough to
be annoying.
* The names don't follow the usual `-ref' and `-set!' covention. (I
always have trouble remembering that it's `hash-table-put!', not
`hash-table-set!'.)
* We'd like more things to have the same API, such as a dictionary
that provides constant-time functional update.
Here's the current plan to deal with those problems:
* Change `hash-table-get' to `table-ref'.
* Change hash-table-put!' to `table-set!'.
* Change "hash-table" in most other function names to just "table":
`hash-table-count' -> `table-count'.
* Add some property for creating new kinds of tables. The property
value supplies an implementation for `table-ref', etc.
* Leave the name `make-hash-table' and `make-immutable-hash-table' as
they are, on the grounds that they create a specific kind of table.
Also leave the `#hash' and `#hasheq' notations alone. Keep
`hash-table?', but also add `table?'.
* Add `hash-table-set' (no "!"), which takes an table and functionally
produces an extended one. Immutable hash tables would support this
operation, and mutables one wouldn't. Note that `#hash()' and
`#hasheq()' become useful base cases for inductively building up a
table with `hash-table-set'.
* Add `table-remove', the functional complement of `table-remove!'.
* Add `for/table', which builds an immutable hash table.
Since lots of `hash-table-...' functions change names in `scheme/base',
this will break lots of v3.99 code. (Of course, the `mzscheme' module
would export the old names.) We'd also have to pick a new name for the
`table' datatype in Scribble, and no doubt in other places.
It's a late in the v3.99 series to make changes like this, but tables
seem important enough to do it anyway --- and important enough to favor
this change over hundreds of other potential improvements that won't
happen in v4.
This plan is tentative, but it will happen very soon if we don't
discover serious problems with it.
Matthew