Fork me on GitHub

Hey all, I would like to understand better what happens when Clojure namespaces get loaded and reloaded. I guess I need to understand more about bytecode, classloaders and Clojure compilation process. Any good resources on that?


@dev964 see if this slide helps a bit


thanks @reborg that helps a bit - I still need to understand what classloaders do though. never got to that level ...


So one step back, something like or in general, search "custom classloaders in Java" to have an idea of what Clojure does on an industrial scale (one new classloader each re-evaluation)


ok, thanks! I'll read up on that!


I have an idea for a repl-helper library for dealing with large output in data structures ... tests, etc. To do it, I need to change the printer, but only for REPL output. I know you can dynamically bind for the REPL thread, but I think this isn't sufficient. Has anybody done this>


@U0ECYL0ET look at unravel, it has an ellipsis system


ahh, this is nice, but seems to only be for lazy data structures. Mine are strict and huge.


I don't think it's only for lazy ones, it works for {} too.


the printer is lazy.


Do you have a way to get this to work with vim-fireplace, since it's not nREPL?


vimpire works with it.


but that is a fireplace alternative, not a fireplace plugin


is there any clojure library mapping Olson time zone to .NET TimeZoneInfo ? for instance "America/New_York"----> "Eastern Standard Time"


@tony what is a Olson time zone?


@sveri IANA in the TZDB


@tonywang897in clojure this is the timezone library to go to: I dont know if it handles timezone conversion. Otherwise I would just use the java.time package as it does timezone handling as its expected.


clj-time does't have anything like that

sveri13:04:51 -> LocalDateTime ldt = LocalDateTime.ofInstant(timestamp, ZoneId.systemDefault());


java 8 made this pretty easy


I would anti-recommend all the Clojure time libraries (yes, every last one of them). They are at best white gloves for interop, at worst misunderstand the underlying library designs.


Just use java.time. That tutorial @sveri linked is A+


- Veteran Clojure programmer


After using clj-time on and off I would agree with this


java time is pretty great.


although I'm still not sure if I "get" how to use it safely


even clj-time doesn't recommend clj-time "Note that from Java SE 8 onwards, users are asked to migrate to java.time (JSR-310) - a core part of the JDK which replaces this project."


you really don't need any wrapper. novice users just need to know a few java Classes, how to call instance methods and class methods (java "static" methods)


after that, clojure's core library takes over


I might recommend thin Cljc wrapper for Java.time + Closure library, if good one existed. Or at least library that provides Transit readers/writers and implementations for java.jdbc/clojure.jdbc read/write protocols. No reason to re-implement this in every project.


That would be valuable, unifying the two would probably be very difficult though? Or is there similarity?


If you don't attempt to completely abstract them away, but only provide most common functions you'd need in cljc code, it is possible. I have one for JodaTime that I should rewrite to Java8:


question regarding spec.alpha . For following example,

(s/fdef close-enough? :args (s/cat :m double? :n double?) :ret double?)
(defn close-enough? [m n] (< (Math/abs (- m n)) 0.0001))
(stest/instrument `close-enough?)
, both m and n have double requirement per spec. Is there another way to write the spec requirements that groups args with same type?


similar to how in golang, you can group multiple args with same type together a la

func close-enough? (m, n double) double {
    // blahblah


or is the example above of (s/cat :m double? :n double?) the most concise it can be?

Alex Miller (Clojure team)19:04:20

personally, I think this is good as is

Alex Miller (Clojure team)19:04:09

but you could also spec :args in various other ways, like (s/coll-of double? :count 2)

Alex Miller (Clojure team)19:04:29

that is less good for several reasons

Alex Miller (Clojure team)19:04:38

1) you’ve lost the arg names in the conformed version of the args, which you’ll want if you use this for docs (like (doc close-enough?)) or in a :fn spec 2) you’ve probably made it harder to evolve the spec with further arg changes 3) function signatures are syntax (heterogenous values where order matters and regex ops like cat are designed for exactly that). coll-of is really designed to represent data. So cat communicates better.


Is it a general good idea/convention/idiom, when designing a mini DSL, to use lists instead of vectors in cases where the first element is special? For example I have a function which takes nested sequential data. if there is an internal list, it will check the truthiness of the first value to determine weather to include the remaining elements in the resulting flat vector.

[:key1 :key2 [(> 2 1) :key3 :key4 [(odd? 32) :key5]] :key6] => [:key1 :key2 :key3 :key4 :key6]
I currently use vectors for the nested "lists" but is this a spot where it's clearly better to force the use of lists?

Alex Miller (Clojure team)19:04:38

the major downside of using lists in a dsl is that you must quote to make literal data


oh yeah, I think i just overlooked that major aspect

Alex Miller (Clojure team)19:04:19

if you’re not actually having people type it in, then that’s not a factor


I was thinking this was a macro but it's a function so would require quoting

Alex Miller (Clojure team)19:04:06

even so, it does communicate different intent and I think that in this example it does read better (but may also imply eval-like things that you don’t wish to imply)


looks like the domain for expired today?


This domain name expired on 2018-04-09 19:29:37 
Click here to renew it.


Hi, I'm calling on the output of nios createTempDirectory, and I get > actual: java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: sun.nio.fs.UnixPath when I run it in a test. However, it seems to work when I do it in the repl. I'm confused 😄 Any ideas?


you are loading some code in the repl that is extending Coercions to work with a UnixPath


(or some other code that is part of your repl is loading it)


@hiredman What could that be? I am not aware of anything like that, and I also didn't do any requires or similar in the repl


it could be just about anything, what repl are you using?


Sorry, was interrupted... I am using emacs+cider, my user profile is empty