This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-23
Channels
- # announcements (2)
- # beginners (246)
- # boot-dev (1)
- # braveandtrue (3)
- # calva (13)
- # cider (26)
- # cljs-dev (6)
- # clojure (75)
- # clojure-finland (4)
- # clojure-germany (39)
- # clojure-italy (1)
- # clojure-mexico (1)
- # clojure-nl (14)
- # clojure-spec (61)
- # clojure-uk (104)
- # clojurescript (125)
- # cursive (20)
- # datomic (1)
- # emacs (2)
- # figwheel-main (91)
- # fulcro (29)
- # graphql (9)
- # jobs (3)
- # jobs-discuss (9)
- # juxt (13)
- # liberator (2)
- # luminus (1)
- # off-topic (15)
- # parinfer (8)
- # re-frame (70)
- # reagent (35)
- # reitit (24)
- # remote-jobs (5)
- # ring-swagger (3)
- # shadow-cljs (127)
- # spacemacs (34)
- # yada (6)
Hello, i’m struggling on something:
(do
(refer 'clojure.core :exclude '[cat])
(def cat 0))
is this supposed to emit a warning?if you're evaluating that in the context of a namespace that already imported clojure.core
, yes
thank you, do you know how can i evaluate something before importing clojure.core? I’ve got namespaces that (load ...) files after the ns form and those loaded files are containing the previously posted form.
you probably want to load those files in the context of a temporary namespace that doesn't import clojure.core
when writing a macro, is there a way to say if x emit symbol else emit nothing
@roklenarcic you have to return a valid clojure expression - nil
at the very least
solved it
~@
with nil
@veddha.riady i've answered this in a thread at #beginners
is (doseq...)
done async?
Do I remember correctly someone observing that Clojure Applied uses records fairly heavily? I'm trying to remember what Alex said about that (and whether he's changed his position any since writing that)? (I don't want to @ him right now since he doesn't show "green")
Yes. I just reread that book and it does. It then goes on to validate the records using Prismatic Schema. That has all been washed away by clojure.spec?
I'm a few chapters away from the records chapter in Getting Clojure. I'll probably take that as the current, informed opinion on records.
Alex speaks about this on episode 143 of cognizant. Discussion of book and spec stars at 18:30
Cool, I'll try to find time to listen to that later today!
in some future version records will be less prominent and spec will replace schema
I'm trying to find the size in some multiple of bytes of given objects and was trying to use Java's Instrumentation
class but was having some trouble. Is there a better approach to this? I'm hoping to be able to log the size of ingested data into a system for metric purposes
Did you try to use VisualVM?
does anyone have any working examples of building an async api web project? i'm cool with using aleph, http-kit, ring, compojure, anything, that works and does the basic stuff (send/receive json) and isn't error-prone. i've been trying to get an async web server up and running for the past 2-3 days and the experience has been pretty terrible
i've yet to see a full POST example for async in yada either on the web
the only async webserver stuff I've done was built on top of https://github.com/mrniko/netty-socketio which was a requirement because using socket io was a requirement, but that required a lot of building up to get anywhere. free of the socket io requirement I think I would start with pedestal
for what its worth, the difference between synchronous ring/compojure and async pedestal is not much per the web frameworks benchmarks game.
anyone know a good POS tagger for clojure?
nvm found a few
https://clojurians.slack.com/archives/C03S1KBA2/p1535045799000100 still curious if anybody has experience with this
Not sure if this does what you want, but your question reminded me of it: https://github.com/clojure-goes-fast/clj-memory-meter
Hey! If anyone have a idea: https://stackoverflow.com/questions/51993246/a-cond-threading-macro-alternative-that-refers-last-threaded-state-inside-pred
Maybe with this syntax?
(let [params {:a 1 :b 1 :c nil :d nil}]
(cond$-> params
(:a $) (update :b inc)
(= (:b $) 2) (assoc :c "here")
(:c $) (assoc :d "here")))
;;=> {:a 1, :b 2, :c "here", :d "here"}
is there a good place to find what the POS tags actually stand for? Like what is RB
and CD
?
@leontalbot At work we have condp->
and condp->>
that thread through the predicate as well as the expression and that's usually enough:
(let [params {:a 1 :b 1 :c nil :d nil}]
(condp-> params
:a (update :b inc)
(as-> p (= (:b p) 2)) (assoc :c "here")
:c (assoc :d "here")))
is :c apply to original params or new version of it?
New version. It threads through everything.
Nice!
close-sourced?
Well, it's part of our production code base. We haven't turned it into a library yet because it's just "utilities".
nice!
@micahasmith Maybe I should just open source our little worldsingles.clojure.extensions
namespace... People keep asking for these things 🙂
condp-> -- an extension to cond-> that threads the expression
through the predicate(s) as well as the result(s).
condp->> -- an extension to cond->> that threads the expression
through the predicate(s) as well as the result(s).
condq -- a version of condp that accepts a unary predicate and omits the
expr (that condp uses as the second argument to the predicate).
dissoc-all -- an extension to dissoc that dissoc's a sequence of keys.
flip -- a companion to partial that allows the first argument to be
omitted (rather than the trailing arguments). Inspired by Haskell's flip.
interleave-all -- an extension to interleave that uses all elements
of the longer sequence argument(s).
@seancorfield oh, yeah definitely. i will very gladly open source our helpers.clj
file of misc helpful fns and macros as well. always wonder what those look like at other companies
(and how many bugs we're unaware we have in ours...)
☝️:skin-tone-2: Yes, a very good reason to open source something -- more 👀 on it!
I have been happily using seancorfield/boot-tools-deps:0.4.5
with deps.edn projects lately. A must have to be able to work with deps.edn and aot projects 🙂
are partial functions (partially applied functions) not as first class as they could be?
rules-engine.core> (replace {"inc" (partial + 1) "0" 0} '("inc" "0"))
(#function[clojure.core/partial/fn--5380] 0)
rules-engine.core> (eval *1)
IllegalArgumentException No matching ctor found for class clojure.core$partial$fn__5380 clojure.lang.Reflector.invokeConstructor (Reflector.java:163)
i was thinking that would work just as this does:
rules-engine.core> (replace {"+" + "1" 1 "2" 2} '("+" "1" "2"))
(#function[clojure.core/+] 1 2)
rules-engine.core> (eval *1)
3
sort of by accident because of this special case in eval it does work for some function objects
(#function[clojure.core/partial/fn--5380] 0)
<- that isn't a form?
the fact that (#function[clojure.core/+] 1 2)
will eval
is an accident?
you are effectively feeding the output of eval into the input of eval, and the domain and range of eval are different
accident is maybe a strong word, unintended consequence of a decisions to support some other features
so maybe i should be doing it like this:
rules-engine.core> (replace {"inc" '(partial + 1) "0" '0} '("inc" "0"))
((partial + 1) 0)
rules-engine.core> (eval *1)
1
ah, just read the link you sent.