This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws (16)
- # beginners (14)
- # boulder-clojurians (1)
- # braveandtrue (184)
- # cider (9)
- # cljs-dev (17)
- # cljsrn (10)
- # clojure (70)
- # clojure-austin (16)
- # clojure-finland (2)
- # clojure-germany (4)
- # clojure-italy (6)
- # clojure-nl (6)
- # clojure-sanfrancisco (2)
- # clojure-spec (5)
- # clojure-uk (60)
- # clojurescript (82)
- # cursive (1)
- # data-science (1)
- # datomic (13)
- # defnpodcast (1)
- # docker (82)
- # figwheel-main (18)
- # fulcro (51)
- # funcool (6)
- # jobs (13)
- # jobs-discuss (5)
- # jobs-rus (7)
- # juxt (2)
- # leiningen (4)
- # lumo (5)
- # mount (1)
- # off-topic (38)
- # pedestal (9)
- # re-frame (13)
- # reagent (16)
- # shadow-cljs (70)
- # spacemacs (5)
- # specter (9)
- # sql (8)
- # tools-deps (2)
- # vim (6)
@peterwestmacott I always feel the remarkable thing is when we actually talk about clojure on this channel. 😉
I’m directing a play, which is on in a couple of weeks: https://www.ticketsource.co.uk/whats-on/surrey/archway-studio-theatre/wasted
In this case, lots of fun. It's a smallish cast, and they're all excellent, so we can really sink our teeth into the text.
At least half the battle is getting the right people to audition in the first place.
@dominicm I feel like I need to say - you know our partial vs anon fn conversation of a few weeks ago? I was doing some data structure wrangling at the weekend, reached for a partial, decided to do it your way, and it's actually probably more readable, so fair play 😉
but for shifting the argument order in a thread, just defining an anon (and then refactoring if it's useful elsewhere) is actually super readable
what was the upshot of the conversation? (I missed it) When to use
(fn ...) and
Is there a way to "unwrap" an instance of a java numeric type (e.g. java.lang.Double) when the numeric type might be a variety of different things (but guaranteed to be
Aww... I like partial in some instances, esp when doing higher order functions that have lookups and other things passed in
yep 100% ... I think I'm won over in the case of threading (i.e. not using partial to shift argument order) but there are cases I'll still use it
@cddr I suspect you're into rolling your own function here, I've not encountered this.
@otfrom it's not as readable though, because the call interface isn't very well defined.
If it extends java.lang.Number it should have shortValue(), intValue() etc. methods available, I think
@conor.p.farrell I'm guessing that he wants to use the one appropriate for each type, automatically.
Yeah background is I'm trying to pass a value returned from one API that returns an object, to the other which has a method overload for each supported primitive type.
https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/Metric.java#L40 into https://github.com/riemann/riemann-java-client/blob/master/riemann-java-client/src/main/java/io/riemann/riemann/client/EventDSL.java
I think you’ll need a code path for each primitive type you’re using. Even if it’s just a branch in a
cond or something.
Having to care about the data type (to me) usually means something is slightly wrong
but in my opinion, it’s the scar across the Java language that is primitives vs. objects
The past cannot be changed, I've learned this from many science fiction stories
many Java APIs have one method for objects and eight almost identical methods for primitives
you could hide it a bit with a multimethod or something but I’m not sure that’s any better than an obvious / explicit branch
if something is slightly wrong it’s usually better to make subsequent maintainers aware of it I feel
I've not been contributing much because I've been wading through season 3 of Twin Peaks.
Regarding the question above... here's what I ended up with. Also replaces +-inf with +-max-value because I've seen influxdb (the eventual target) choke on infinity before.
(defn bridged-metric "Bridges the kafka metric API with the dropwizard API by taking the supplied `kafka-metric` and returning an object that satisfies both interfaces. This allows the underlying kafka metrics to participate in dropwizard's registry. The additional information provided in the `MetricName` is thus made available to the reporter for event tagging purposes" [kafka-metric] (let [metric-name (.metricName kafka-metric) value (fn [x] (let [-inf? (fn [n] (= n (Float/NEGATIVE_INFINITY))) +inf? (fn [n] (= n (Float/POSITIVE_INFINITY)))] (condp instance? x Integer (.intValue x) Double (cond (-inf? x) (Double/NEGATIVE_INFINITY) (+inf? x) (Double/POSITIVE_INFINITY) :else (.doubleValue x)) Float (cond (-inf? x) (Float/MIN_VALUE) (+inf? x) (Float/MAX_VALUE) :else (.floatValue x)))))] (reify org.apache.kafka.common.Metric (metricName [this] (.metricName kafka-metric)) (metricValue [this] (value (.metricValue kafka-metric))) com.codahale.metrics.Gauge (getValue [this] (value (.metricValue kafka-metric))))))