sci

2023-03-05T22:07:08.943639Z

@borkdude I’m able to copy-ns that problematic namespace now

🎉 1
2023-03-05T22:13:41.858709Z

I was searching around for examples again to figure out what the current recommended way to handle macros is. It seems like if I add ^:macro metadata to an ordinary defn, clojure sees it differently and I can’t call it normally anymore, so I can’t just pull out all my macro implementations into ^:macro-anotated versions that I can then directly add to sci via copy-var.

2023-03-05T22:14:03.591069Z

I am somehow confused about :macro and :sci/macro and how that fits together

2023-03-05T22:14:45.935289Z

right now I’m (a) pulling out my macro implementations into their own functions, and then (b) creating yet another function that I tag with ^:macro to copy-var into sci, and that seems like maybe more work than should be needed

2023-03-05T22:16:42.219679Z

eg.

;; implementation fn
(defn redef:impl [form env name & args] ...)

;; macro
(defmacro redef [name & args] (apply redef:impl &form &env name args))

;; sci version
(defn ^:macro redef:sci [form env name & args] (apply redef:impl &form &env name args))

;; elsewhere, adding to the namespace 
{'redef (copy-var redef:sci the-ns)}

borkdude 2023-03-05T22:18:31.595799Z

@mhuebert Are you talking about macros from .clj or .cljs?

2023-03-05T22:22:49.740149Z

currently it’s a cljc project that works in both

borkdude 2023-03-05T22:28:21.289919Z

so when you do it in a JVM on a normal function:

(defn ^:macro [])
will turn the function in a real JVM macro

borkdude 2023-03-05T22:28:43.666079Z

which is probably not what you want

borkdude 2023-03-05T22:29:14.445999Z

does that redef:impl has to exist in the JVM context at all?

borkdude 2023-03-05T22:29:51.949059Z

if not, ^:macro still works: #?(:cljs (defn redef:impl ^:macro [...]))

borkdude 2023-03-05T22:30:28.773669Z

I'd have to check if ^:sci/macro also works on a var, but it's getting late now.

borkdude 2023-03-05T22:30:33.474039Z

I'll check tomorrow

2023-03-05T22:33:50.016839Z

k thanks! I don’t think ^:sci/macro works on a var, I believe I tried that awhile back

borkdude 2023-03-05T22:34:31.430269Z

we could maybe make that work

borkdude 2023-03-05T22:34:42.587169Z

in copy var

borkdude 2023-03-05T22:35:01.123789Z

yeah, I don't think there's anything wrong if we supported that

borkdude 2023-03-05T22:35:04.546909Z

PR welcome

borkdude 2023-03-06T09:14:44.378389Z

I'm fixing it right now

borkdude 2023-03-06T09:19:17.206459Z

@mhuebert should work now on master