Open benknoble opened 3 years ago
The syntax has undergone a slight adjustment (less parens).
I've also added catch/match
for using match patterns.
docs and impl have been improved, but the concepts remain fairly similar
Thank you for your contribution!
If you haven’t already please take the time to fill in the form https://forms.gle/Z5CN2xzK13dfkBnF7
Bw Stephen
See also https://github.com/benknoble/try-make-sarna-happy and the docs on the package server (when ready).
Macro
with-handlers
anddynamic-wind
can be used to implementcatch
andfinally
, respectively, but in the traditional Lisp-like format they read "backwards"—handlers are shown long before the actual "main code." Fordynamic-wind
this may not be terrible (see go'sdefer func
for a similar finally clause that comes ahead of the code). In general, though this is hard to read.try
flips the script: it presents the body code first, a series of exception-handlers in an optional catch, and an optional finally block.Example
Here are some examples from the scribble documentation:
Before and After
It tidies up a common pattern and makes it read in a forward direction. In this it is similar to the threading library but for exceptions.
There are many before/after examples in the docs.
Licence
I affirm that I am submitting this code under the same MIT License that the Racket language uses. https://github.com/racket/racket/blob/master/racket/src/LICENSE-MIT.txt and that the associated text is licensed under the Creative Commons Attribution 4.0 International License http://creativecommons.org/licenses/by/4.0/