This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-03
Channels
- # beginners (37)
- # boot (5)
- # cider (3)
- # clara (19)
- # cljs-dev (188)
- # cljsrn (1)
- # clojure (104)
- # clojure-russia (5)
- # clojure-spec (1)
- # clojure-uk (3)
- # clojurescript (41)
- # core-async (1)
- # data-science (4)
- # datascript (3)
- # figwheel (7)
- # fulcro (14)
- # garden (4)
- # graphql (3)
- # jobs-discuss (2)
- # leiningen (9)
- # london-clojurians (1)
- # off-topic (5)
- # onyx (2)
- # portkey (6)
- # re-frame (9)
- # reagent (5)
- # shadow-cljs (2)
- # specter (1)
- # uncomplicate (2)
I don't really need threading or anything like that. I just need a way to group a collection, which may be slow to produce, into batches of a defined size.
But I cant help but feel like theirs a better option than basically going through a java version of JSON.parse(JSON.stringify(..))
maybe it's better for cli
to provide a error message rather than throw a NullPointerException
when there's no -main
?
@emccue everything in jvm clojure is an instance of some java class - what class do you need to create?
I would just write coercion functions. If you really want to get fancy, write a macro that loads the class, uses reflection, and writes your coercion functions for you.
sadly clojure only makes it easy to create objects implementing a defined interface
you coul use defprotocol to define the methods you want to implement then reify that protocol, but that's a little odd
smells like transducers to me
Andy Fingerhut has a repo with some fine grained benchmarks. Maybe too fine.
http://jafingerhut.github.io/clojure-benchmarks-results/Clojure-benchmarks.html
is anyone aware of any writing about passing maps instead of single arguments in Clojure? I want to know when it is and isn’t a good idea.
only https://stuartsierra.com/2010/01/15/keyword-arguments-in-clojure, which is a little outdated because Clojure now has built-in support for keyword arguments
I added a print statement to https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L3706 (InvokeExpr#emit) just to get an understanding of what’s going on
now, at the repl, I see this:
user=> (defn foo [a b] (+ a b 3))
#'user/foo
user=> (foo 1 2)
fn -> EMIT name:user$eval8278 internal name:user$eval8278 thisName: null
6
looking at how the repl is defined in main.clj, I see this at the beginning of defn repl
:
(let [cl (.getContextClassLoader (Thread/currentThread))]
(.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl)))
I guess this might be a piece of the puzzle?https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L4972-L4982
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/DynamicClassLoader.java#L44-L49
Is this a good way to implement prefix tries (for autocomplete for example) in clojure - https://gist.github.com/joelkuiper/a422cea41a26c9a3e2b35ac3abbb06f8
except it just gets loaded into memory instead of being written to a file and loaded from it
So when the class loader loads the class, it has to get "evaled" somehow? How do you know which method you're supposed to call on the resulting class?
I guess the class loading machinery has it's work cut out for it when dealing with Clojure... And I don't even want to think about the security implications of class loading 😂
@schmee The JVM does, yeah. The JVM is much more dynamic than the Java source language might lead you to believe.
Java gets a lot of hate, but the more I dig into Java, the JVM, and Clojure the more impressed I get
So much exciting stuff on the horizon: value types, vector api, pattern matching, graal... Good times for JVM langs!
how do I give a type hint to clojure that a method on genclass returns a List of another class
There has to be SOME information i could give so my gen'ed classes dont just get seen as returning ungenerified lists
Is there anything tying ClassLoader hierarchies and Clojure? I'm not interested in isolating clojure versions particularly, nor in total isolation, I want an actual hierarchy.
the jvm really doesn't want two classes with the same name visible from the same place in the cassloader hierarchy, so to do things like pass clojure data around between runtimes you would still need to serialize and de-serialize which is as good a definition for isolation as there is
what I mean is, runtime 1 won't be able to treat a PHM from runtime 2 as a PHM, but, depending on what you are doing it would likely recognize the PHM as a java.util.Map impl
Then what is different between whatever you are proposing and just normally running Clojure?
@emccue Not sure if it'll help your quest but all the Contrib libraries are built and tested with Maven at the moment so maybe look at the pom.xml
files there?
If they share a Clojure runtime, they are the same clojure and there is no difference hierarchy or isolated or whatever
And clojure code, unless explicitly written in a way to do otherwise, will all lookup classes the same way
@seancorfield Thats helpful and ill look through some more of them now
Ive gotten it to the point where calling mvn clojure:compile
works fine, but It doesnt seem like its hooking in to the regular compile cycle
The very little I know about Maven, I've learned from dealing with pom.xml
files in the various Contrib libs that I maintain ¯\(ツ)/¯
@emccue Something else to look at would be the pom.xml
generated by clj
for a deps.edn
project, but I'm not sure whether it generates a complete compile/test XML file for that...
Right. But I want to fill it with a list, then splice that into something else later.
I suppose I could have two macros, one computes the result-set, the other expands it as needed.
user=> (defmacro foo [] (let [x [1 2 3]] `(let [x# ~x] x#)))
#'user/foo
user=> (macroexpand-1 '(foo))
(clojure.core/let [x__168__auto__ [1 2 3]] x__168__auto__)
user=> (foo)
[1 2 3]
I think my error was wanting the macro to return multiple values, rather than a list of some sort.