This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-09
Channels
- # beginners (108)
- # boot (14)
- # cider (8)
- # clara (13)
- # cljs-dev (63)
- # cljsrn (5)
- # clojure (57)
- # clojure-brasil (1)
- # clojure-italy (69)
- # clojure-losangeles (10)
- # clojure-nl (6)
- # clojure-poland (2)
- # clojure-spec (6)
- # clojure-uk (50)
- # clojurescript (116)
- # core-async (1)
- # cursive (9)
- # data-science (8)
- # datascript (4)
- # datomic (43)
- # duct (2)
- # editors (1)
- # fulcro (29)
- # instaparse (7)
- # jobs (6)
- # keechma (3)
- # mount (16)
- # off-topic (61)
- # om (10)
- # onyx (5)
- # parinfer (17)
- # pedestal (2)
- # portkey (5)
- # quil (2)
- # re-frame (84)
- # reagent (9)
- # remote-jobs (2)
- # ring-swagger (2)
- # shadow-cljs (17)
- # slack-help (1)
- # tools-deps (29)
- # vim (23)
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?
Ops, no image upload on slack, srry. Just a sec. Here it is: https://www.dropbox.com/s/dddc6nbj4ne6jfp/Screen%20Shot%202018-04-09%20at%2011.03.21.png?dl=0
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 https://www.journaldev.com/349/java-classloader 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.
is there any clojure library mapping Olson time zone to .NET TimeZoneInfo ? for instance "America/New_York"----> "Eastern Standard Time"
@tonywang897in clojure this is the timezone library to go to: https://github.com/clj-time/clj-time 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.
https://docs.oracle.com/javase/tutorial/datetime/iso/instant.html -> LocalDateTime ldt = LocalDateTime.ofInstant(timestamp, ZoneId.systemDefault());
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.
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)
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: https://github.com/metosin/metosin-common/blob/master/src/cljc/metosin/dates.cljc
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
}
personally, I think this is good as is
but you could also spec :args in various other ways, like (s/coll-of double? :count 2)
that is less good for several reasons
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?the major downside of using lists in a dsl is that you must quote to make literal data
if you’re not actually having people type it in, then that’s not a factor
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)
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: #'http://clojure.java.io/Coercions 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