Last active
October 16, 2020 16:46
-
-
Save wandersoncferreira/aa808c9570fda8df6a08d5e94be3bae6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defmacro demangle [sym] | |
(let [prefix# (str (gensym)) | |
name# (symbol (str prefix# sym)) | |
fn# `(defn ~name# [] (str (quote ~sym)))] | |
`(-> ~fn# | |
var-get | |
class | |
str | |
(clojure.string/split (re-pattern ~prefix#)) | |
last | |
(clojure.string/split #"__\d") | |
first))) | |
(demangle !*&#-+=$%.><?|) | |
;; => "_BANG__STAR__AMPERSAND__SHARP___PLUS__EQ_$_PERCENT__DOT__GT__LT__QMARK__BAR_" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment