Created
October 11, 2014 17:55
-
-
Save pjstadig/0b28ac50bf6319f877b4 to your computer and use it in GitHub Desktop.
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
Clojure 1.7.0-alpha2 | |
user=> (definline my-get [m k default] `(let [m# ~m k# ~k] (if (not (contains? m# k#)) ~default (get m# k#)))) | |
#'user/my-get | |
user=> (my-get {:a :b} :a (throw (Exception. "foo"))) | |
:b | |
user=> (my-get {:a :b} :not-found (throw (Exception. "foo"))) | |
Exception foo user/eval20 (NO_SOURCE_FILE:3) | |
user=> (apply my-get [{:a :b} :a (throw (Exception. "foo"))]) | |
Exception foo user/eval24 (NO_SOURCE_FILE:4) | |
user=> (apply my-get [{:a :b} :a :not-found]) | |
:b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment