Fork me on GitHub
JB Seo01:04:24

Hello, I have a question on the latest release v0.5.2. ā€¢ fix fn defs to be at compile-time (thanks!) Does it work well with leiningen? With leinignen, uberjar with option 'aot all & omit-source' still throws 'Can not read file' exception. Test project:

JB Seo01:04:07

Honestly, I don't understand why switching 'def-db-fns' from macro to a normal function would prevent executing it on runtime (so that it will not read SQL file on start up.)


@jbseo The assumption is that you are calling (def-db-fns) as a top-level form in your namespace so when you load the ns (for compilation) it runs and loads the SQL and defines all the functions. If you're calling (def-db-fns) anywhere, it's not going to work.


(at least, that's my reading of the changes made in 0.5.2)

JB Seo02:04:42

With the following file:

(ns hello.echo)

(prn "I am hello.echo")
I will see the greeting message both on AOT compilation time and on starting the program. Am I right?


I'm just guessing at their intent: I'm not saying it actually works if the source is not present in the JAR file šŸ™‚ I don't know how well it has been tested...

JB Seo02:04:13

I see, Thanks!


In #126, the OP says "Indeed it does work! (Plus the conversion from using macros to regular functions cleans up the core code.)" so the solution worked for their use case...


(that convo suggests it does work for them since they are excluding .sql files from their JAR...)

JB Seo02:04:40

Yes, so I wonder how it could be possible. With the definition of, I think it should read SQL file on start up time.


I just tried it with your repro project and even with a few tweaks and edits, I cannot get it to work "as advertised" so it definitely "doesn't work" as I would expect.


You could create a new issue and link back to #126 and your repo.


Yes, this is still not working (even with depstar as in the original issue). I've updated that bug, and will try to get a fix out in the next few days. I'll probably switch back to macros.


It's a tricky one -- and macros vs functions is irrelevant I think since the issue is about invocation at load time which happens for both compilation and for running in a standalone JAR.