This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-08
Channels
- # announcements (12)
- # aws (4)
- # beginners (92)
- # calva (2)
- # cider (28)
- # clara (11)
- # clj-kondo (5)
- # cljdoc (9)
- # cljs-dev (195)
- # cljsjs (1)
- # clojure (82)
- # clojure-italy (18)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-spec (10)
- # clojure-uk (51)
- # clojurescript (40)
- # cursive (7)
- # datomic (19)
- # duct (9)
- # emacs (2)
- # figwheel (3)
- # fulcro (56)
- # graphql (8)
- # jobs (3)
- # luminus (2)
- # off-topic (15)
- # re-frame (5)
- # reitit (3)
- # ring (5)
- # shadow-cljs (22)
- # slack-help (2)
- # sql (51)
- # test-check (9)
- # vim (64)
- # yada (1)
Is there a common trick to have clojure.walk/postwalk
stop walking a data structure similar to how reduced
can be used to stop reduce
in walking a list?
Nope, unless you check something stateful like an atom
I have a hacky solution that walks a structure twice, but I'll try to come up with something better
here's an implementation of walk
/`prewalk`/`postwalk` over an AST that can be terminated via reduced
@bronsa Cool, thanks
I just came up with this
(defn postwalk-reduced [f form]
(clojure.walk/walk
(fn [x]
(if (reduced? x)
(unreduced x)
(postwalk-reduced f x)))
f
form))
(defn postwalk-reduced-demo [form]
(postwalk-reduced (fn [x] (print "Walked: ") (prn x) x) form))
(comment
(postwalk-reduced-demo {:a (reduced {:b 1})})
(postwalk-reduced-demo {:a {:b 1}})
)
Very basic, but seems to do what I want so far
(i probably have it wrong. I'll experiment a bit more and report later)
actually postwalk seems more complicated, but with prewalk I get what i want - stop changing nested datastructures)
(do
(defn prewalk-reduced [f form]
(clojure.walk/walk
(fn [x]
(if (reduced? x)
x
(prewalk-reduced f x)))
unreduced
(f form)))
(prewalk-reduced (fn [x]
(if (and (seq? x) (contains? #{'fact 'facts} (first x)))
(reduced x)
(if (= '=> x)
'=?>
x)))
'(5 => 5
1 => 1
(fact
2 => 2
(fact => 1)))))
Looks like deref-to-map (private in clojure) does this:
(let [[ex val]
(when-not pending
(try [false (deref o)]
(catch Throwable e
[true e])))])
makes sense
Anyone experienced in solving leaked sockets stuck in CLOSE_WAIT status? as reported in https://github.com/http-kit/http-kit/issues/326 Seems relatively common in JVM servers. http://www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.html has some some promising advice which seems to apply to my case: > Don't design a protocol whereby a client connects to the server every minute and does so by opening a new connection. Instead use a persistent connection design and only reconnect when the connection fails But still, our usage of http-kit is pretty vanilla so maybe there's a hard-and-fast fix
Has anyone here experimented semi-extensively (aka more than just a hello world) with GraalVM’s native images for Clojure? I am curious as to whether it works well enough to use in production on a medium-sized project.
pushing such an experimental thing to production, when normal jvms exist and run java bytecode great seems like such a bad decision
like, all my experience with clojure professionally has been writing backend systems with it, and the jvm works great there, so it is just so hard to see any upside
I'm pretty down on native-image and my personal opinion is that we spend a disproportionate amount of time fetishizing fast startup
I see a lot of projects and when I run lein deps :tree
or clj -Stree
i'm always astonished
a feature of targeting the jvm is getting access to all the libraries, so people go nuts with them
indeed; thanks @lilactown for specifying 😛
As @lilactown said my use case is to run the application in a serverless setting; multi-seconds startup times of the JVM are unacceptable there unfortunately 😞
anyways you're going to sink a lot of time into just getting native-image to compile on anything but the most trivial projects
many people have spent time getting graalVM native image to play... you won't be able to take a random jar or dependency and compile it blindly. Look into jaotc
@hmaurer, it doesn't have any of the restrictions that native-image has
if Java is ice cream, graal native-image is "frozen dairy treat" jaotc is still ice cream
@ghadi I see; and does jaotc work with most hjars then? and does it speed up startups a lot?
The following doesn't appear to work - I see no meta
changes:
(alter-var-root #'something vary-meta assoc :deprecated true)
Any ideas?
right! thanks, had forgotten about that one 🙂
I would have expected the alter-var-root
to work though
I'm trying to create vars to mimic the mathml structure, and there's a tag named true
, which I obviously can't def
. Is there a good suffix I should use? I'm reserving *
for the function versions (unless I go for true** I guess?)
I like that, my only hesitation is that completion for tr
wouldn't pick it up I guess :thinking_face:
Hmm, I'm trying to write a macro which writes a macro, and I'm getting a bit stuck with doing the unquote splicing in the nested defmacro. Any wizardry?
How fast is the startup of a hello world program with jaotc compared to Graal native?
Probably because it is an uncommon use case? I don't recall anyone ever asking for one before.
What languages have such a thing?
I need it for some basic modulo arithmetic, it's easy enough to define on my own but it seemed like an odd omission
it seems, that the roots of many decisions in Clojure came from the Java. maybe this case is the same?
I'm not sure, but would Math/floorDiv
be related to what you want?
returns largest int smaller than the or equal to the quotient
for performance reasons clojure only goes far from the java Math stuff for opt-in accuracy reasons
so if what I'm looking for mathematically isn't a correctness / precision improvement, I usually check the java.lang.Math API
I see, so the difference is that clojure.core functions take in all sorts of polymorphic types like BigInts and Ratios at the expense of some performance?
more importantly they have contexts where they auto-promote to preserve accuracy, if you opt in
eg. use +'
instead of +
, inc'
instead of inc
or use /
instead of quot or java interop (?)