Fork me on GitHub
#clojure
<
2018-03-18
>
ackerleytng09:03:44

I have a test case that occasionally fails, but i don't think i introduced any randomness, could someone help me take a quick look?

ackerleytng10:03:05

seems like for the test to consistently pass, I have to (:import [ UnknownHostException]) before referring to UnknownHostException in the test

ackerleytng10:03:52

previously in the (thrown-with-msg?) form, i just directly said (thrown-with-msg? java.net.UnknownHostException ...) directly

joelsanchez12:03:52

I have a function erroneously called to-json, which takes a Datomic entity and simplifies/denormalizes it such that it's easier to consume from dumb clients (dequalifies keywords, expands subentities, translates i18n entities depending on user's language, removes sensitive attributes...) What would be a better name? denormalize? simplify? dumbify? output? Naming things is hard.

benzap12:03:20

I usually use an arrow for conversions

benzap12:03:35

datomic-clj->json

benzap12:03:11

you could also consider represent-json

benzap12:03:31

as in, it's a representation for dumb clients

benzap12:03:36

represent-dumb

joelsanchez12:03:42

json has some sense but at the same time it has nothing to do with json

joelsanchez12:03:01

particularly when I use transit, not json ... 😂

benzap12:03:04

yeah idk, I guess it depends on how far reaching

joelsanchez12:03:29

I think I will go with ->client or smth, until I find a better one : p

benzap12:03:16

I ran into the same issue for conversions between clj and a database... I still think about the naming conventions as being incorrect haha

qle-guen15:03:33

hey, I need to attach a java annotation to a clojure function. Do I need gen-class or deftype for that?

pez16:03:11

Why can’t I evaluate this in a clj repl? (It works in figwheel cljs repl.)

#?(:clj  "clj"
   :cljs "cljs")

Alex Miller (Clojure team)20:03:38

because the Clojure repl does not support conditional read. That’s only supported when reading cljc files. The cljs repl uses tools.reader with a different set of defaults.

pez14:03:39

Thanks! Is there a way to allow it, you think?

Alex Miller (Clojure team)15:03:44

we intentionally decided not to make that a default feature of the clojure repl, so not planning to change that. you can explicitly invoke the reader with the conditional read features enabled, or you could start your own sub repl with any reader you like

pez15:03:55

Yeah, that’s what I mean’t, if there is a way for me to allow it. I’d like to be able to evaluate forms in cljc files, and sometimes I need them to be evaluated by the clj session and sometimes by the cljssession. Where should I start reading? 😃

Alex Miller (Clojure team)16:03:23

For invoking the reader, here’s an example:

Alex Miller (Clojure team)16:03:26

(read-string {:read-cond :allow :features #{:clj}} "#?(:clj \"clj\" :cljs \"cljs\")")

Alex Miller (Clojure team)16:03:13

the options map turns on reader conditionals and injects the feature :clj - you could instead say :cljs if you want to pretend to be in ClojureScript

Alex Miller (Clojure team)16:03:14

if you want to create a sub repl, that’s a bigger topic but ultimately boils down to calling clojure.main/repl with appropriate hooks (custom :read option)

pez17:03:48

Thanks again. This is very helpful! I think I will need to go the sub repl path. I am writing an extension for Code where the user can switch between cljs and clj repl sessions for cljc files.

pez16:03:51

(I get RuntimeException Conditional read not allowed.)

stardiviner17:03:46

Does Clojure support DTrace like in this like https://en.wikipedia.org/wiki/DTrace said,

With a supported language provider, DTrace can retrieve context of the code,
including function, source file, and line number location. Further, dynamic
memory allocation and garbage collection can be made available if supported by
the language. Supported language providers include *assembly language*, *C*, *C++*,
*Java*, *Erlang*, *JavaScript*, *Perl*, *PHP*, *Python*, *Ruby*, *shell script*, and *Tcl*.

Application providers allow DTrace to follow the operation of applications
through system calls and into the kernel. Applications that offer DTrace
application providers include *MySQL*, *PostgreSQL*, *Oracle Database*, *Oracle Grid
Engine*, and *Firefox*.

Alex Miller (Clojure team)21:03:43

Java has btrace that integrates into DTrace https://github.com/btraceio/btrace. should theoretically work with Clojure although I don’t ever recall seeing anyone try.

bobcalco18:03:28

I am running into a problem running 'lein repl' where after adding amazonica to my project.clj, 'lein repl' fails with 'CreateProcess error=206, The filename or extension is too long'

bobcalco18:03:43

Anyone have ideas how I should configure jvm opts to fix this? I noted that amazonica pulled down a zillion more jar files and probably blows up the command line call lein is making behind the scenes, but I doubt it's specific to amazonica as a google search shows this problem popping up in lots of other contexts.

gklijs19:03:24

@bob592 is that on Windows?

gklijs20:03:32

You could try have your root folder at a higher level, not sure if there are better solutions.

brunobraga20:03:47

does anyone know a good clojure boilerplate project for server side? with endpoints and all..Ideally that uses datomic.

gklijs20:03:10

Try #luminus, you can setup a project with some options

bobcalco20:03:22

@gklijs Is there a known limitation in terms of classpath length, and does it affect some operating systems (Windoze!) and not others?

bobcalco20:03:21

@gklijs I can rename my project and what-not to have a shorter root name, as I imagine that adds up, but it would be nice to know how to compute the maximum # of jars I can add to my classpath. This can be a serious restriction unless there is a sensible way around it.

gklijs21:03:28

It not the number of jars, but more likely just one with a lengthy group,name or package name. I use Mac OS myself, but ran into problems sometimes on Windows. So when working on virtualized windows or something, I like tip have something like c:/dev to put projects in, instead of using my home folder.

dominicm20:03:42

@bob592 it's not about number of jars. It's about the code that's generated.

andrewboltachev20:03:56

Hello! Is this project https://github.com/Datomic/codeq now abandoned? Are there any other similar ones (whcih perform git repo [possibly of a Clojure project] analysis in general)?

bobcalco20:03:33

Why does adding 'amazonica' make it blow up but not anything else? I can only imagine it has to do with the huge # of jars it imported as dependencies.

Alex Miller (Clojure team)21:03:40

I don’t see any evidence that CLJ-1852 is the culprit here. Could be, but could be something else too. Have you tried just printing the classpath with lein classpath and using Java directly?

razum2um21:03:19

Anyone know a macro(?), which checks not a general expr, but has access to last result: (let [x (expr)] (when (f1 x) (let [y (expr2 x)] (when (f2 y) (expr3 y))))) => (cond-result-> (expr) f1 expr2 f2 expr3)

bobcalco21:03:44

@alexmiller This is far from scientific, but without 'amazonica' 'lein classpath' fills up ~4.25 pages of a new default Google doc. With 'amazonica' it fills a full 9 pages. So, 'amazonica' slightly more than doubles the size of my classpath with all its dependencies.

Alex Miller (Clojure team)21:03:36

did you try using that classpath to run java -cp <classpath> clojure.main ?

bobcalco21:03:08

without amazonica, happy. With amazonica, an error as above.

Alex Miller (Clojure team)22:03:51

is there more to the error? stack trace?

bobcalco22:03:31

Resolved to sift through it after dinner.

bobcalco22:03:02

the big difference is lein repl is first trying to compile a CLJS front end (due to my configuration in project.clj). So the path to doom is slightly different as it's invoking the CLJS compiler when this happens via 'lein repl'.

triss23:03:29

Is there a clojure.walk/postwalk-replace that only replaces the first instances found and leaves the rest untouched?

hmaurer23:03:43

Hi! I would like to write a very simple REPL in Clojure, taking arbitrary string input (not clojure syntax). I wrote a 5 lines function looping over read-line, but it doesn’t handle left/right arrows (rlwrap). Is there any way I can add support for this easily?

hmaurer23:03:18

Or is there a library to do this?