workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
<@Dannette> is *your* project AOT’ed? and if so, have you cleaned?
2017-10-27T10:15:25.000644
Sonny
clojurians
clojure
i guess he's AOTing his project
2017-10-27T10:15:31.000406
Kareen
clojurians
clojure
ah! yes, that was it. Didn't occur to me that AOT could cause this problem :disappointed:
2017-10-27T10:15:48.000087
Dannette
clojurians
clojure
<@Dannette> usually when you're seeing LinkageError/NoSuchMethodError/VerifyError in clojure, it's caused by AOT compilation
2017-10-27T10:22:18.000164
Kareen
clojurians
clojure
Short, probably stupid question: `(partition 5 5 [\space] "cseerntiofarmit on")` Why does this not fill the last partition up to 5 elements? Wouldn’t it be supposed to do that when given a pad?
2017-10-27T11:40:11.000633
Jon
clojurians
clojure
&gt;&gt;&gt;In case there are not enough padding elements, return a partition with less than n items.
2017-10-27T11:42:27.000356
Evan
clojurians
clojure
Must have overseen that. Thanks. Is there no simple way to always keep exactly 5 elements and fill the rest with a given pad?
2017-10-27T11:43:23.000416
Jon
clojurians
clojure
`(partition 5 5 (repeat \space) "cseerntiofarmit on")`
2017-10-27T11:43:35.000656
Guillermo
clojurians
clojure
<@Guillermo> there we go :smile: thanks! i forgot about that :confused: still new :smile:
2017-10-27T11:44:20.000626
Jon
clojurians
clojure
this might be a silly question, but is there a way to wipe clean all unknown derivations? something like an `(underive)` that takes no parameters?
2017-10-27T12:25:24.000611
Zola
clojurians
clojure
<@Zola> there’s global-heirarchy
2017-10-27T12:27:25.000212
Margaret
clojurians
clojure
or maybe i should be working with a hierarchy object, store it somewhere, and wipe it when necessary
2017-10-27T12:27:32.000264
Zola
clojurians
clojure
yeah - that’s much cleaner
2017-10-27T12:27:44.000756
Margaret
clojurians
clojure
okay, thanks :slightly_smiling_face:
2017-10-27T12:27:54.000520
Zola
clojurians
clojure
actually using hierarchies isn't exactly well trodden ground
2017-10-27T12:28:20.000136
Rebeca
clojurians
clojure
<@Rebeca> derive, underive, and defmulti all use them - they just default to the global
2017-10-27T12:28:50.000061
Margaret
clojurians
clojure
right
2017-10-27T12:28:58.000187
Rebeca
clojurians
clojure
but even derive and underive on the global hierarchy are not very common
2017-10-27T12:29:21.000514
Rebeca
clojurians
clojure
i think in my 7 years of writing clojure i've used derive twice, never underive
2017-10-27T12:30:53.000458
Kareen
clojurians
clojure
so I am just saying, advice and best practices on using hierarchies(born out from experience) is going to be thin on the ground
2017-10-27T12:31:51.000100
Rebeca
clojurians
clojure
in my scenario i've built a mock file system in the browser from a tabular data source where each row only knows its parent id. when i read in the rows i derive its id with its parent id, and then i can easily grab all descendants without having to mapify or recursively iterate through the rows.
2017-10-27T12:36:11.000605
Zola
clojurians
clojure
it felt quicker and more performant, but i guess it's somewhat stateful as well?
2017-10-27T12:37:01.000215
Zola
clojurians
clojure
sure, definitely
2017-10-27T12:37:12.000361
Rebeca
clojurians
clojure
you are using a hierarchy to get a mutable map
2017-10-27T12:37:34.000433
Rebeca
clojurians
clojure
what could go wrong!
2017-10-27T12:37:44.000182
Zola
clojurians
clojure
you could just use a map in an atom
2017-10-27T12:37:57.000025
Rebeca
clojurians
clojure
(a hierarchy is just a map in a ref, so not all that different implementation wise, but semantics I guess)
2017-10-27T12:38:58.000482
Rebeca
clojurians
clojure
gotcha. it was just an experiment / lazy way to not build and manage a tree myself. in that regards, success. :wink:
2017-10-27T12:40:04.000549
Zola
clojurians
clojure
thanks for the advice guys
2017-10-27T12:40:10.000652
Zola
clojurians
clojure
Is there a way for us to override a protocol implementation on a type coming from a transitive library namespace?. Lets say I am consuming a library and it defined to look at a specific field on a Avro type and I want myself to override that lookup for my own usecase.
2017-10-27T12:41:13.000367
Lizabeth
clojurians
clojure
`extend-protocol` is just a macro around `extend` which is just a function
2017-10-27T13:32:16.000487
Jonas
clojurians
clojure
so if you have the protocol, the type you would like to override, and the implementation, you should be able to just pass that to extend at runtime
2017-10-27T13:37:27.000086
Jonas
clojurians
clojure
<@Jonas> The library already has a extend protocol on the type and I want to make sure for my project my own extend protocol on the same type overrides the implementation coming from the library and moreover the protocol itself is defined in the library.
2017-10-27T13:53:36.000497
Lizabeth
clojurians
clojure
when you say for your own project, does that mean your code will use one implementation and in the same program, the library’s code will use a different implementation for the same protocol?
2017-10-27T13:55:52.000375
Jonas
clojurians
clojure
protocols are not locally bindable like that - there’s only one implementation possible per concrete class
2017-10-27T14:01:48.000631
Margaret
clojurians
clojure
if your implementation is defined later, it replaces a previous definition for that specific class (if it existed)
2017-10-27T14:02:18.000386
Margaret
clojurians
clojure
I want to completely replace the definition. how do I ensure that my implementation is the one that is picked up at runtime?
2017-10-27T14:03:58.000449
Lizabeth
clojurians
clojure
I just tried a dummy example and it looks like you get `IllegalArgumentException class MyType already directly implements interface MyProtocol for protocol`
2017-10-27T14:04:02.000484
Jonas
clojurians
clojure
when you try to replace the implementation
2017-10-27T14:04:34.000049
Jonas
clojurians
clojure
``` (defprotocol MyProtocol (f1 [_])) (defrecord MyType [] MyProtocol (f1 [_] 1)) (clojure.core/extend MyType MyProtocol {:f1 (fn [_] 2)}) ```
2017-10-27T14:04:45.000004
Jonas
clojurians
clojure
but ```(defprotocol MyProtocol (f1 [_])) (defrecord MyType [] ) (clojure.core/extend MyType MyProtocol {:f1 (fn [_] 1)}) (clojure.core/extend MyType MyProtocol {:f1 (fn [_] 2)})```
2017-10-27T14:06:30.000310
Jonas
clojurians
clojure
works
2017-10-27T14:06:31.000476
Jonas
clojurians
clojure
yea, in the above example, lets say the first extend is in namespace1 and second extend(override) is in namespace2 and a third namespace uses namespace1, namespace2. I don't know if I can guarantee that namespace2 extend is always picked over namespace1. May be there is nothing I can do here but want some input for my usecase.
2017-10-27T14:09:43.000179
Lizabeth
clojurians
clojure
if you wrap your extend in a function, then you can just call it at the top of your `-main`
2017-10-27T14:13:34.000026
Jonas
clojurians
clojure
```;; namespace 2 (defn do-my-extend! [] (extend MyType MyProtocol {:f1 (fn [_] 2)})) ;; main namespace (defn -main [&amp; args] (do-my-extend!))```
2017-10-27T14:13:38.000014
Jonas
clojurians
clojure
the -main will probably run after all the top level code
2017-10-27T14:14:01.000624
Jonas
clojurians
clojure
alternatively, if you have access to the source of the library you’re consuming, it might be worth considering just creating your own fork
2017-10-27T14:14:27.000559
Jonas
clojurians
clojure
Thanks. I will try with the first approach.
2017-10-27T14:16:09.000433
Lizabeth
clojurians
clojure
EDIT: question moved to <#C073DKH9P|re-frame>
2017-10-27T15:05:06.000377
Berry
clojurians
clojure
I want to read and write XML but I see there are `clojure.xml`, `clojure.data.xml` and `clojure.data.zip` to choose from. Does anyone have experience with these? Do they complement each other?
2017-10-27T15:46:22.000211
Kyra
clojurians
clojure
I had to do some xml parsing at some point and ended up using clojure.data.xml. clojure.data.xml can parse lazily. I’m not sure if clojure.xml can also parse lazily and without loading the xml document into memory
2017-10-27T16:01:42.000144
Jonas
clojurians
clojure
seems like clojure.data.xml is a better than clojure.xml option unless you really only need very basic xml parsing functionality
2017-10-27T16:09:20.000041
Jonas
clojurians
clojure
<@Jonas> thanks, I’ll give that a spin :sunglasses:
2017-10-27T17:24:49.000012
Kyra
clojurians
clojure
Does programming shape the way you think? A research project: <https://twitter.com/leraboroditsky/status/924006274852892672> Comments to <#C03RZGPG3|off-topic> , please.
2017-10-27T18:03:14.000152
Lucia
clojurians
clojure
anyone with core.logic experience here?
2017-10-28T11:56:17.000048
Isabell
clojurians
clojure
in particular core.logic.fd
2017-10-28T11:56:31.000030
Isabell
clojurians
clojure
i'm stuck with a relation i'm trying to implement
2017-10-28T11:59:06.000096
Isabell
clojurians
clojure
(map + a b) -&gt; c (where a b and c are lists of ints)
2017-10-28T11:59:51.000076
Isabell
clojurians
clojure
what does it mean by Returns a new coll consisting of to-coll with all of the items of from-coll conjoined? does it iterate over the whole collection or just joining them together?
2017-10-28T12:00:11.000030
Anneliese
clojurians
clojure
<@Anneliese> remember values are immutable, so you'll receive a new collection with all items conjoined.
2017-10-28T12:24:20.000072
Bibi
clojurians
clojure
There's more detail "under the covers" but you can think of this as a "copy" of the to-coll and from-coll conj'ed into a 3rd collection.
2017-10-28T12:25:31.000108
Bibi
clojurians
clojure
Well, conj of course doesn't join 2 collections, so excuse that part of my explanation.
2017-10-28T12:27:43.000057
Bibi
clojurians
clojure
Still you'll have a copy, and the original from-coll is still the same.
2017-10-28T12:28:57.000001
Bibi
clojurians
clojure
What explanation are you referring to in your original question?
2017-10-28T12:29:42.000061
Bibi
clojurians
clojure
<@Anneliese>if i'm not mistaken you're asking about `into`, which does `(reduce conj to from)`, so it does iterate
2017-10-28T13:16:01.000054
Evan
clojurians
clojure
Is anyone using dire error handling? How does it work with multimethods?
2017-10-28T14:26:42.000069
Lesia
clojurians
clojure
Which library do you use to connect a Clojure app to a relational database?
2017-10-28T17:47:59.000007
Mina
clojurians
clojure
I'm surprised when I see anything other than clojure.java.jdbc used to connect / communicate, but there are many options for DSLs that construct queries
2017-10-28T17:49:10.000071
Margaret
clojurians
clojure
I like hugsql together with conman.
2017-10-28T17:51:40.000067
Elwanda
clojurians
clojure
<https://www.hugsql.org/>
2017-10-28T17:51:54.000069
Elwanda
clojurians
clojure
<https://github.com/luminus-framework/conman>
2017-10-28T17:52:19.000049
Elwanda
clojurians
clojure
<@Margaret> do you write strings for your queries?
2017-10-28T17:54:52.000069
Mina
clojurians
clojure
no, but I'm 100% certain you shouldn't use the query generating library I use
2017-10-28T17:55:35.000036
Margaret
clojurians
clojure
I don't get it, from your answer I realized you are using `jdbc`
2017-10-28T17:57:30.000057
Mina
clojurians
clojure
jdbc is not a query generator, it's a connection library, which is what your question asked for
2017-10-28T17:57:50.000031
Margaret
clojurians
clojure
Any preferences for a library to manage and handle queries and transactions? From the OOP world, something like an ORM?
2017-10-28T17:59:53.000079
Mina
clojurians
clojure
<@Mina> Since there are no "objects" in Clojure, there's no need for ORM. `clojure.java.jdbc` is the "standard" contrib library for JDBC work -- `[org.clojure/java.jdbc "0.7.3"]` is the latest version -- <https://github.com/clojure/java.jdbc/> -- community documentation <http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html>
2017-10-28T19:36:49.000077
Daniell
clojurians
clojure
(disclaimer: I maintain this library)
2017-10-28T19:37:11.000080
Daniell
clojurians
clojure
That library "handles queries and transactions". You have a hash map you want stored in a table? `(jdbc/insert! db-spec :table my-hash-map)` Simple as that.
2017-10-28T19:38:29.000070
Daniell
clojurians
clojure
If you want transactions over multiple operations: ```(jdbc/with-db-transaction [conn db-spec] (jdbc/insert! conn :table my-data) (jdbc/insert! conn :other-table more-data))```
2017-10-28T19:40:03.000073
Daniell
clojurians
clojure
If you want a DSL for composing SQL queries, I highly recommend `honey-sql` (linked from the community documentation above).
2017-10-28T19:41:40.000023
Daniell
clojurians
clojure
<@Mina> If you really want something ORM-like in Clojure, check out Korma (also linked from the community documentation above). I thought it had stopped being maintained a long time ago but it appears to have a new maintainer... My experience has been that people quickly run into limitations with Korma and end up dropping it. YMMV.
2017-10-28T19:44:53.000045
Daniell
clojurians
clojure
For small and specifically performance-sensitive sections in a program, is it possible to write "imperative with local mutable variables" style code using Clojure? In other words, is it possible to "write Java in Clojure"? The closest thing I could find were volatiles, and those are still one extra layer of boxing, right?
2017-10-28T21:10:20.000014
Araceli
clojurians
clojure
For what it's worth, I understand this goes heavily against the idioms of Clojure in the standard case.
2017-10-28T21:11:24.000038
Araceli
clojurians
clojure
<@Araceli>, if you're thinking of writing "Java in Clojure", why not just write the Java code and call that? What I mean is, Java's a very good Java, if that's what you want :slightly_smiling_face:
2017-10-28T21:27:01.000006
Bibi
clojurians
clojure
you can write “java in clojure”
2017-10-28T21:28:08.000046
Jonas
clojurians
clojure
<@Bibi> Yes, that's the other option. Mainly, the benefit from a theoretical "Java in Clojure" would be locality/organization of the source files, for whatever that's worth.
2017-10-28T21:28:18.000001
Araceli
clojurians
clojure
depending on how much performance you need to eek out
2017-10-28T21:28:48.000032
Jonas
clojurians
clojure
most of the code I’ve seen that focuses on performance talks about type hints to avoid reflection which is one of the slower parts
2017-10-28T21:29:42.000030
Jonas
clojurians
clojure
<@Jonas> I'm looking for on-par with writing regular imperative Java. Which is to say, I need mutable locals in an unboxed form.
2017-10-28T21:30:00.000062
Araceli
clojurians
clojure
are you creating lots of volatiles?
2017-10-28T21:30:16.000018
Jonas
clojurians
clojure
Yes, and using things like transient collections, as long as they don't leak outside the function.
2017-10-28T21:30:36.000005
Bibi
clojurians
clojure
you may be able to create them once and reuse them, depending on the context
2017-10-28T21:30:37.000004
Jonas
clojurians
clojure
For now, it's purely hypothetical. I want to know if I have this option available before I get into it.
2017-10-28T21:30:44.000045
Araceli
clojurians
clojure
Because, whether I do or don't have this option available will probably change what I do.
2017-10-28T21:31:14.000027
Araceli
clojurians
clojure
because other than creation, I think it’s the same as just regular java mutation
2017-10-28T21:31:18.000001
Jonas
clojurians
clojure
Can you be more clear by what you mean with "write Java in Clojure" though? There's a wide scope of what it *could* mean.
2017-10-28T21:32:27.000082
Bibi
clojurians
clojure
<@Bibi> Say I take a generic computer algorithms textbook. It has well-known algorithms in a form that can be translated near-verbatim into Java, same as any other traditional imperative language. If I wanted to do the same for Clojure, and maintain Java-level performance, my (admittedly limited) understanding is that I would need mutable locals.
2017-10-28T21:34:13.000044
Araceli
clojurians
clojure
I see. I haven't tried (at least on purpose) to program imperatively in Clojure having spent so much energy to leave Java behind :slightly_smiling_face: I can't think of anything beyond mutability you'd need, it seems all flow control mechanisms are there.
2017-10-28T21:37:59.000062
Bibi
clojurians
clojure
For the most part, I try to learn and write idiomatic Clojure. But for that low-single-digit percent of code that needs it, I'm exploring options for getting Java-level performance.
2017-10-28T21:39:05.000040
Araceli