![]() The new argument to `hash-iterate-value` and most other `...-hash-iterate-...` functions determines a result to be returned in place of raising a "bad index" exception. For most kinds of hash tables, a "bad index" exception will only happen when the provided index is wrong or when a hash table is mutated during an iteration. Mutation during iteration is generally a bad idea, but in the case of a weak hash table, a potential background mutation by the garbage collector is difficult to suppress or ignore. Adding an option to control bad-index behavior makes it easier to write loops that defend against uncooperative tables, including loops where a hash-table key disappears asynchronously. Racket's printer was already using this functionality internally, so the change to `hash-iterate-value` and company mostly exposes existing functionality. The `in-hash` form and related sequence constructors similarly support a bad-index alternate value so iterations can handle that case explicitly. They do not use the new bad-index support implicitly to skip missing entries, because that idea does not play well with the iteration API. A hash-table index can go bad after `in-hash` has selected the index and determined that it should be used for the next iteration, and a sequence can't take back that decision. |
||
---|---|---|
.. | ||
common | ||
converter | ||
envvar | ||
error | ||
file | ||
filesystem-change-evt | ||
foreign | ||
format | ||
host | ||
locale | ||
logger | ||
network | ||
path | ||
port | ||
run | ||
sandman | ||
security | ||
sha | ||
srcloc | ||
string | ||
subprocess | ||
unsafe | ||
bootstrap-main.rkt | ||
bootstrap-thread-main.rkt | ||
demo-thread.rkt | ||
demo.rkt | ||
demo2.rkt | ||
main.rkt | ||
Makefile | ||
README.txt |
This directory implements the port, path, encoding, printing, and formatting layer. It can be run in a host Racket with `make demo`, which is useful for development and debugging, but it's meant to be compiled for use in Racket on Chez Scheme; see "../cs/README.txt". Core error support must be provided as a more primitive layer, including the exception structures and error functions that do not involve formatting, such as `raise-argument-error`. The more primitive layer should provide a `error-value->string-handler` paramemeter, but this layer sets that parameter (so the primitive error function slike `raise-argument-error` won't work right until this layer is loaded). Thread and event support is similarly provided as a more primitive layer. Running `make demo` doesn't rely on that, while running `make demo-thread` uses the thread implementation in "../thread" to demonstrate cooperation between the layers.