-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try—a try/catch/finally for sarna #9
Comments
The syntax has undergone a slight adjustment (less parens). I've also added |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/
The text was updated successfully, but these errors were encountered: