racket/racket/src/io
Matthew Flatt b7392a688e hash-iterate-value & co.: add an optional bad-index result
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.
2018-07-31 10:14:07 -06:00
..
common switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
converter switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
envvar switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
error switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
file io: repairs 2018-07-03 17:26:38 -06:00
filesystem-change-evt switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
foreign cs & io: repairs for locks & DLL errors 2018-03-23 19:20:14 -06:00
format switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
host thread: don't always convert end-atomic to a thread swap 2018-07-17 16:23:17 -06:00
locale switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
logger thread: don't always convert end-atomic to a thread swap 2018-07-17 16:23:17 -06:00
network switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
path io: another repair to Windows path parsing 2018-03-23 21:46:12 -06:00
port io: repairs 2018-07-03 17:26:38 -06:00
print hash-iterate-value & co.: add an optional bad-index result 2018-07-31 10:14:07 -06:00
run switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
sandman switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
security switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
sha add sha1-bytes, sha224-bytes, and sha256-bytes via rktio 2018-06-27 06:36:20 -06:00
srcloc switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
string switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
subprocess switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
unsafe switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
bootstrap-main.rkt switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
bootstrap-thread-main.rkt switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
demo-thread.rkt switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
demo.rkt add sha1-bytes, sha224-bytes, and sha256-bytes via rktio 2018-06-27 06:36:20 -06:00
demo2.rkt switch to a new, Racket-implemented expander & module system 2018-02-26 13:19:53 -07:00
main.rkt add sha1-bytes, sha224-bytes, and sha256-bytes via rktio 2018-06-27 06:36:20 -06:00
Makefile expander: repair and further improve flattener 2018-06-14 17:27:00 -06:00
README.txt io: repairs for Windows path maniplation 2018-03-23 10:37:59 -06:00

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.