This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-11
Channels
- # announcements (1)
- # aws (4)
- # beginners (16)
- # cider (9)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (46)
- # clojure-brasil (1)
- # clojure-spec (3)
- # clojure-uk (4)
- # clojurescript (46)
- # cursive (26)
- # duct (1)
- # emacs (31)
- # figwheel (1)
- # fulcro (9)
- # graalvm (21)
- # kaocha (1)
- # nyc (1)
- # off-topic (4)
- # pathom (6)
- # planck (45)
- # re-frame (2)
- # reagent (11)
- # ring (5)
- # rum (9)
- # spacemacs (2)
- # sql (60)
- # tools-deps (3)
Basically what you're saying is that InterceptorComponent
describes a superset of IntoComponent
behavior and thus anything that extends InterceptorComponent
implicitly can implement IntoComponent
. Trying to extend the one protocol onto the other lies madness, but you could write an adapter fn that returned a reify
ed instance with implementations for both IntoComponent
and InterceptorComponent
. It would be indistinguishable from the input value (with regards to the InterceptorComponent
protocol...) and could also participate in the IntoComponent
protocol.
Alternatively, if you actually could implement IntoComponent
with your new protocol, an implementation of IntoComponent
can be expressed entirely in terms of the interface InterceptorComponent
. Extension is just saving you having to write the IntoComponent
implementations when you're defining your record/type, so why not macro your way out of that hole with e.g. definterceptorcomponent
which expands to deftype
with the IntoComponent
protocol specs tacked onto the end of the user supplied body?
it's intentional that protocols cannot be extended onto protocols. that said, protocols are nothing more than maps of functions and as such, there are ways to programatically get this effect. generally though, I've had better luck by extending a protocol to Object, then using conditional code to dynamically extend the concrete type you've received (which satisfies some secondary protocol) to the first protocol
are there tools to provide performance details (mainly time-to-run) of all functions called from a parent function at runtime? i have a main function that kicks off loads of queries, calculations etc. i could time
each one, but given how nested this code is i was hoping for an automatic solution.
I've used tufte ( https://github.com/ptaoussanis/tufte ) and its defnp
with good results
Hi I’m trying to write my own client for a telnet-like protocol, for a mud game. I need to parse a byte stream, and the type of messages are identified by some special bytes, you know, just like telnet.
it uses ByteBuffer, which has all the methods needed for pulling other types out of bytes
in fact, that's straightforward enough that I'd skip clojure libs / bindings and just feed the InputStream into a ByteBuffer via interop, and use that API
i’ve used https://github.com/ztellman/gloss before. e.g. in https://github.com/wiseman/turboshrimp/blob/master/src/com/lemondronor/turboshrimp/navdata.clj
can I package all the dependencies in one uberjar, and my code in another jar. So I can deploy the dependencies only once(if no dependency changes).
Is it possible to use Cognitect's AWS library with Ring? I reported one dependency issue when using both libraries in #aws channel.
@kari.marttila looks like a dependency conflict with Jetty which you should be able to fix by specifying a compatible version directly in project.clj
.
@emccue slurp it in, break it into statements (str/split on ;), and call db-do-commands on each one
@seancorfield, thanks. I'll check that tomorrow.
It worked. @seancorfield: thanks for your help!
Yeah something like that
When I'm at my computer I'll pull up the code we use at work to do the same thing
Execution error (SQLException) at org.sqlite.core.NativeDB/throwex (NativeDB.java:478).
The prepared statement has been finalized
You probably need to tell db-do-commands not to use a transaction
Hard to debug when I'm on my phone 🙃 If you can post more details in #sql I can take a look when I'm at my computer later
I remember looking into migratus for something. But use a different separator and split on that. I thought I remember the underlying thing not liking terminating semi colons
I don't know if this is the issue, but clojure.string/split
has some non-intuitive behavior with separators at the end. TLDR; use a negative limit
parameter. See https://clojuredocs.org/clojure.string/split for some examples. I got bitten by this recently.
I think the end result was that the batched statements can’t have terminating semicolons (this was on Postgres not sure what your dB is)
The split ended up producing an empty SQL statement and that's what throws the exception.
(str/split contents #";\s*\n")
or (str/split contents #";.*\n")
should I use *ns*
to get the qualified symbol in macro? like (my-macro (+ 1 2))
, I want +
as clojure.core/+
.
You want to use syntax quoting in this case
`x => clojure.core/+
'+ => x
Can you explain more about what you're trying to do?
user=> (defmacro my-macro [x] (first x))
#'user/my-macro
user=> (my-macro (+ 1 2 ))
#object[clojure.core$_PLUS_ 0x1f38957 "[email protected]"]
user=>
The symbol is clojure.core/+
here.In case this helps:
user=> (defmacro my-macro [x] (.ns (resolve (first x))))
#'user/my-macro
user=> (my-macro (+ 1 2 ))
#object[clojure.lang.Namespace 0x707b1a44 "clojure.core"]
user=>
(-> (call (/ 1 0))
(then (inc))
(then (/ 2)))
;; => #error {
;; :cause "Divide by zero"
;; :via
;; [{:type java.lang.ArithmeticException
;; :message "Divide by zero"
;; :at [clojure.lang.Numbers divide "Numbers.java" 188]}]
;; :trace ...}
(-> (call 1)
(then (inc))
(then (/ 3)))
;; => 2/3
(->> (call 1)
(then (inc))
(then (/ 3)))
;; => 3/2
(some-> {:a 1 :b 2}
(then (:a))
(then (/ 2)))
;; => 1/2
(some->> {:a 1 :b 2}
(then (:a))
(then (/ 2)))
;; => 2
(some-> {:a 1 :b 2}
(then (:c))
(then (/ 2)))
;; => nil
(some->> {:a 1 :b 2}
(then (:c))
(then (/ 2)))
;; => nil
This is what I have currently.