Fork me on GitHub

The require expression happens at runtime but the next form's symbol is needed at compile time


That makes a lot of sense. Thanks @ghadi


first thing that comes to mind is pass in the random generation functions to your library so that during tests you can pass in more predictable ones


if you have different types perhaps centralize it as a single map that can be passed in with those different fns


Generally with fp it's much easier to do dependency injection without mocking the import system, since the functions should accept all it needs to generate it's output


by using random functions your functions are no longer pure


I've also seen examples of being used for something like this


there's also integrant which seems to be a newer one as a response to component


I'm using for isolated deps, and I've run into that dependencies from directories (e.g. git) aren't available during require but are for io/resource, I was hoping the issue might be obvious to someone 🙂.


what lib you prefer for dealing with postgresql in clojure ?


I jsut started using next.jdbc, really like it, I'm only using the "plan" with transducers and it's pretty simple.

Jakub Zika15:07:32

Hi, can somebody explain this behaviour? I don't think I encountered it before. Thanks


this is a bda data thing. Keywords treat a slash as the namespace but you're calling keyword on a date that uses the slash to separate the month, day, year. This is a garbage in garbage out type situation


@jakub.zika-extern current-time is the string "07/07/2019". The function keyword turns it's argument into a keyword. So (keyword current-time) will output :07/07/2019. Which is the name 07/2019 in the namespace :07. You can confirm this by calling (namespace (keyword current-time)) and (name (keyword current-time)) in your REPL. So {(keyword current-time) "aa"} outputs {:07/07/2019 "aa"} which gets printed as in your case. What you're seeing is the reader syntax for maps with namespaced keys. For example, {:ns/a "aa" :ns/b "value of b" :ns/c 42} is the same as #:ns{:a "aa" :b "value of b" :c 42}


keyword is more liberal in taking it's arguments than it's contract.


Your example (and this: (keyword ":a")) work but you aren't supposed to do that.

Jakub Zika17:07:36

Thank you guys, really appreciate that!

🍻 4

Is there any intrinsic reason why gen-class requires AOT compilation?


not anymore


there's a ticket to remove this restriction


I understand its there primarily for interop, but it's a frustrating restriction


what’s the use case for dynamically creating a class?


easier dev time


... what is the usecase statically creating classes?


AFAICT static class compilation is just the status quo on the JVM


gen-class literally creates .class files that can be loaded by any java program, so I’m not sure how it would work outside of AOT


Compiling Clojure functions when you type them at the REPL also creates classes, but they need not be written to the file system. Maybe what is being asked about is whether a class can be created in JVM memory without writing it to a file, using gen-class?


There is a private function #'generate-class used to implement gen-class that you could try calling, which I believe does not write to the file system. I've never used it on its own, so do not know if there are any pitfalls from using it directly. gen-class doesn't seem to do much more than #'generate-class plus writing to the file system, though.

👀 8