-
-
Save mhuebert/2221c18e9df11f2fd766 to your computer and use it in GitHub Desktop.
<? macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.macros) | |
(prn " | |
I'm trying to write the <? macro mentioned by David Nolan: | |
... http://swannodette.github.io/2013/08/31/asynchronous-error-handling/ | |
It's my first CLJS macro and I'm not clear on how to write macros | |
in Clojure for ClojureScript. | |
") | |
; throw-err can't be defined in this file, because there is no `js` namespace in Clojure. | |
; It needs to be written in ClojureScript, but referenced from the <? macro. ??? | |
(defn throw-err [e] | |
(if (instance? js/Error e) (throw e) e)) | |
(defmacro <? [expr] | |
`(throw-err (<! ~expr))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment