@sritchie09 as long as the macro produces s-expressions with namespaces that are also valid inside sci, then it should be fine to hook it up as a macro
@sritchie09 @borkdude I copied it because it would not be available in ClojureScript otherwise, for Clojure it worked fine with copy-var
yeah copying is usually the safest strategy
got it! @mkvlr as you can see, finally making a pass
@mkvlr I think I can slim these macros down too… binding macros often look nice paired with a form like let-coordinates*
that takes the things it wants to bind as args
@sritchie09 I think I only made very minor changes like fully qualifying the namespace here https://github.com/sicmutils/sicmutils/pull/216/files#diff-68db231b19f934a25d6bd98078d1f5b6fe90fdc9fa8fb86bdeefe139bc042bd1R34
one more Q for you both if you have a moment!
@mkvlr for some of the macros you were able to do this:
(defn with-literal-functions
[_ _ & args]
`(af/with-literal-functions ~@args))
and just pass the args through to the underlying macro
but then in that let-coordinates macro you linked above, you recreated the body -
would this work, if we fully qualified the namespaces in the original macro?
(defn let-coordinates
[_ _ bindings & body]
`(cc/let-coordinates ~bindings ~@body))
I can test too, just looking for intuition here!
it causes a stackoverflow, hmm
(either one does)
because it is calling itself?
adding printlns sometimes help :)
oh yeah!
probably because it is calling the macro it’s supposed to be rewriting?
if the prefix gets ignored that might do it. I have a better idea for how to deal with this
@sritchie09 the with-literal-function
was also copied from https://github.com/sicmutils/sicmutils/blob/master/src/sicmutils/env.cljc#L86-L88 (I think this exists somewhere else as well?)
good call, I think this is trying to “alias” a macro, which seems to work in non-SCI land
@mkvlr I’ve got everything up and running!! I’m refactoring the macros to make the actual macro part way slimmer so it’s easier to copy
(defn with-literal-functions [_ _ litfns & body]
(let [pairs (af/binding-pairs litfns)
bindings (into [] cat pairs)]
`(let ~bindings ~@body)))
for example
chatting with @jackrusher shortly, after that I’ll send a PR to your PR 🙂
the only thought I’m having is that maybe I should put the duplicate macros inside the namespace where the real one is defined
except I can’t since the name overrides…
oh, wait, never mind
that already happens, based on how you constructed the ns forms in the sci context!
💥
@mkvlr https://github.com/mk/sicmutils/pull/1#pullrequestreview-562757170
okay, that should do it!!
@sritchie09 I’m looking over it right now
@borkdude is https://borkdude.github.io/sci.web/ using an old version of sci? defrecord
doesn’t work there but does in my local sci
yeah, that's pretty old
ah ok
This is more recent: https://babashka.org/xterm-sci/
is this expected?
or how can I recover the type from the record?
Records in sci are really just maps with some metadata on it
there is no real record type, it's just there for compatibility
ah
let me check
this can be fixed I think
$ bb -e '(defrecord Foo []) (meta (Foo.))'
{:sci.impl/record true, :sci.impl/type Foo}
the type is currently not exposed, but instance?
should work on itI need the type as a keyword
maybe just use maps with :type
, is that an option for you?
or do you have some clojure equivalent of these records
this works mostly but it seems to be missing the namespace?
yeah, defrecords are pretty hacky and mostly there to make existing clojure libs works
this can be improved though
feel free to post issue(s)
will do, thanks!