Fork me on GitHub
#clojure
<
2019-07-07
>
ghadi00:07:38

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

dpsutton00:07:10

That makes a lot of sense. Thanks @ghadi

theeternalpulse04:07:57

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

theeternalpulse04:07:47

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

theeternalpulse04:07:39

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

theeternalpulse04:07:27

by using random functions your functions are no longer pure

theeternalpulse05:07:21

I've also seen examples of https://github.com/stuartsierra/component being used for something like this

theeternalpulse06:07:28

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

dominicm10:07:09

I'm using https://github.com/RutledgePaulV/clj-embed 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 🙂.

abdullahibra14:07:27

what lib you prefer for dealing with postgresql in clojure ?

theeternalpulse06:07:12

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

dpsutton15:07:04

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

jaihindhreddy16:07:24

@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}

jaihindhreddy16:07:14

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

jaihindhreddy16:07:53

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
emccue19:07:47

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

bronsa08:07:31

not anymore

bronsa08:07:04

there's a ticket to remove this restriction

emccue20:07:15

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

lilactown20:07:52

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

carkh20:07:49

easier dev time

Aron21:07:16

... what is the usecase statically creating classes?

lilactown21:07:18

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

lilactown21:07:53

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

andy.fingerhut22:07:04

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?

andy.fingerhut23:07:37

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