Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active Jul 30, 2020
Embed
What would you like to do?

Self-hosted:

$ plk
ClojureScript 1.10.597
cljs.user=> (require '[foo.core :refer [defnmy]])
nil
cljs.user=> (defnmy FOO clojure.string/lower-case [x]
       #_=>   (inc x))
#'cljs.user/foo
cljs.user=> (foo 1)
2

Regular:

$ clj -A:cljs/rel -re node -r
ClojureScript 1.10.753
cljs.user=> (require '[foo.core :refer [defnmy]])
nil
cljs.user=> (defnmy FOO clojure.string/lower-case [x]
  (inc x))
#'cljs.user/foo
cljs.user=> (foo 1)
2
(ns foo.core
#?(:cljs (:require [planck.core :refer [requiring-resolve]])))
(defmacro defnmy [name fn args & body]
(let [n (symbol ((requiring-resolve fn) (str name)))]
`(defn ~n ~args ~@body)))
(ns foo.core
(:require-macros foo.core))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment