This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-03
Channels
- # aws (27)
- # beginners (64)
- # boot (14)
- # calva (10)
- # cider (36)
- # cljs-dev (13)
- # cljsrn (79)
- # clojure (58)
- # clojure-berlin (8)
- # clojure-france (1)
- # clojure-italy (18)
- # clojure-nl (9)
- # clojure-russia (1)
- # clojure-spec (28)
- # clojure-uk (29)
- # clojurescript (55)
- # core-async (20)
- # cursive (5)
- # datomic (105)
- # emacs (17)
- # figwheel-main (13)
- # fulcro (20)
- # graphql (4)
- # hoplon (1)
- # hyperfiddle (2)
- # jobs (7)
- # jobs-discuss (110)
- # off-topic (23)
- # pathom (1)
- # perun (2)
- # re-frame (87)
- # reitit (2)
- # shadow-cljs (8)
- # spacemacs (2)
- # tools-deps (118)
- # vim (11)
Does anyone know of a good way to "sandbox" the loading of namespaces? I'm trying to find a way to load and evaluate a namespace from an external source without interfering with the bindings in my current Clojure process' instance of the same namespace.
I made this a while ago for that purpose: https://github.com/RutledgePaulV/clj-embed I keep meaning to come back and update it a bit. If you end up using it let me know and I’ll bring it up to date and cut a new release
There is a mranderson library that can create a "shadowed" version of a namespace, meaning renamed. I have not used it myself, but I know some other libraries have used it: https://github.com/benedekfazekas/mranderson
Thanks guys! I had seen mranderson from where refactor-nrepl uses it to deal with this problem, but that solution seems a little more finicky than I was hoping for. clj-embed looks cool! The classloader solution-route was what I was hoping to find examples for.
In the short term, I think I will forgo the namespace isolation requirement in my project, in order to focus on exercising the other aspects of the project. Later, I'll plan on attempting to incorporate clj-embed. So no hurry @U5RCSJ6BB, but thank you.
@jrsnyder13 Perhaps look at the clojail
project?
That will also make it safe to load and run that code (or at least safer) since it's coming from an external source...
Does anyone have an example of deploying a clojure library to clojars from gitlab-ci?
Is there any syntax that will help me include a specific key/val in a map depending on clojure/clojurescript target?
I know of #?(:clj)
, but usable inside a map form
I can wrap the whole thing in assoc of course, but still
can you use the splicing reader conditional?
I guess not
could use a cond-> whose test is a reader conditional
(cond-> { … } #?(:clj true :cljs false) (assoc :clj-only :foo))
@alexmiller Thanks, splicing reader was what I was looking for.
and for map
{#?@(:clj [:key :val])}
I’m a little surprised that works but I guess it makes sense
A happy accident?
it wouldn’t surprise me if that gives trouble to other tools with their own lexers
Interesting syntax tho, #?@(...)
as it looks like a map with an odd number of elements until it’s read
Does anyone know how to configure the built-in MacOS firewall to permanently accept incoming connections? I've added the version of java to the firewall but I'm stick stuck clicking "allow" each time I restart the server.
Is there any way to determine in custom macro whether passed symbol is macro or function?
of course this doesn't work here
(defmacro is-macro? [sym]
(let [m? (:macro (meta (var sym)))]
`~m?))
(Note that you can't resolve vars in Clojurescript macros.)
I banged on this until it worked. It might not work in all situations though https://github.com/johnmn3/dispacio/blob/master/src/dispacio/alpha/core.cljc#L156
Interesting, thanks!! Earlier I couldn't figure out a way to do it, and just found a way to avoid the need for it, but I'll hang on to this for future reference.
It doesn't work in most ways, you're right. There's just certain situations where you can get it to work.
And I don't understand the interplay well enough to explain when it does or doesn't. But it works there 🙂
Could come in handy.
I have math functions and some of them are expressed as macros (java calls) and some of them are clj functions. I want to wrap such macros into functions (and avoid wrapping functions) to generate rest of the code.
so my macro checks symbol and generated function or leave symbol unwrapped
(if (:macro (meta (resolve f))) `(fn [v#] (~f v#)) f)
which is used in final generated codeone possible gotcha is if you get a function literal instead of a symbol bound to an fn
"cannot embed object in bytecode" is the error message IIRC
fortunately I operate on symbols here, it's a private macro and should be ok in my case
Why recur with objs in one tail, and sorted-objs in another, when both are the same value?
oh I see, there's a path where you want to use sorted-objs, even as objs got rebound, I get it now
maybe there's a way to turn the path that recurs with rest
into a normal reduce, and the one that recurs with sorted-objs into a recur on the enclosing fn?
just a thought
Weird request, but working on a perf improvement to something and want to provide a realistic benchmark on public data. Tried randomly generating data, but issue is time is dominated by things that are artifacts of random data you wouldn't see in practice (for instance, all keywords are distinct and very long). I don't want to try to generate "realsitic data since that seems bad and want to know if someone has some large public batch of EDN data laying around that might be 'representative' of real-world data, or even better something someone's used to benchmark before
mbrainz?