Files
emacs.d/elpa/racket-mode-20180609.1253/try-catch.rkt
Mateus Pinto Rodrigues f6ec2ebf59 Update packages/ Add org-ref
2018-06-11 13:50:46 -03:00

18 lines
537 B
Racket

#lang racket/base
(require (for-syntax racket/base
syntax/parse))
(provide try)
;; Some try/catch syntax. Because `with-handlers` can be
;; exceptionally bass-ackwards when nested (pun intended).
(define-syntax (try stx)
(define-splicing-syntax-class catch-clause
(pattern (~seq #:catch pred:expr id:id e:expr ...+)
#:with handler #'[pred (lambda (id) e ...)]))
(syntax-parse stx
[(_ body:expr ...+ catch:catch-clause ...+)
#'(with-handlers (catch.handler ...)
body ...)]))