This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-06
Channels
- # announcements (18)
- # asami (3)
- # aws (10)
- # babashka (47)
- # beginners (343)
- # calva (36)
- # cider (4)
- # clojure (66)
- # clojure-europe (9)
- # clojure-nl (3)
- # clojure-uk (23)
- # clojurescript (30)
- # community-development (69)
- # conjure (1)
- # eastwood (9)
- # events (7)
- # fulcro (81)
- # graalvm (1)
- # malli (5)
- # meander (1)
- # off-topic (41)
- # pathom (15)
- # rdf (1)
- # reitit (6)
- # sci (57)
- # shadow-cljs (18)
- # spacemacs (4)
- # startup-in-a-month (1)
- # testing (2)
- # vim (1)
@borkdude Q for you, probably should be obvious from watching your discussions with @mkvlr but asking here anyway!
if I have an existing macro that doesn’t use &env
or &form
, is there any way to re-use its definition, or do I have to redefine as a fn?
@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
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)
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
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!
okay, that should do it!!
@mkvlr heading out for a run ~soon, but if you’re around, @mkvlr, happy to take a look at this together or answer any Qs
@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
This is more recent: https://babashka.org/xterm-sci/
$ 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 it