Fork me on GitHub
#clojure
<
2016-09-01
>
sattvik00:09:12

Well, given you need to use gen-class (which is definitely worth confirming), the problem you may be running into is that the class is not created unless you are aot-compiling.

didibus00:09:43

Hum, could be an aot issue

didibus00:09:56

I'm gen-classing so that Spring can call the method

didibus00:09:20

working on a mix java/clojure project

gfredericks00:09:22

spring wants a java class with a particular static method?

sattvik00:09:58

Well, it may be easier to create the class in Java and invoke Clojure from it. There’s an API for that: http://clojure.github.io/clojure/javadoc/

didibus00:09:35

Spring creates a java object, that I then want to pass to my clojure code. So I have a static function in clojure that takes it and sets it for toher clojure function to access it

gfredericks00:09:35

gen-class should be able to do it though; it's just confusing and AOT is no fun

didibus00:09:05

So I use the static invoker bean to inject the other bean into my clojure code

gfredericks00:09:14

if you're controlling the calling code from java, just use the java→clojure api directly

gfredericks00:09:31

unless you need to use beans and then I have no idea what's going on

didibus00:09:00

I'm not though, Spring is in charge. The whole thing is a custom java web server which heavily uses spring

gfredericks00:09:48

okay I'm probably out of my depth; but writing the java class in java sounds cleanest to me

didibus00:09:32

What other options but gen-class do I have to call Clojure from java?

didibus00:09:29

I'm not sure what on that doc page is helpful? IFn?

didibus00:09:33

Oh, I think I see

didibus00:09:48

I can call var on a clojure var, and then call invoke on it

sattvik00:09:20

Pretty much. It’s relatively straightforward, unlike gen-class.

didibus00:09:58

Ok, my problem was that I wasn't using the fully qualified namespace for defining my return type in my gen-class, because I thought the import would work in there also for me to only use the class name, but it does not

didibus02:09:09

Does gen-class default :main to true? So if I don't want a main, I have to set main to false explicitly?

sattvik02:09:37

At least, if you are doing it in the ns form.

didibus02:09:54

Ok, its weird, the doc says if supplied and true a main will be generated

sattvik02:09:39

Well, that’s the case if you are invoking gen-class directly. The doc for ns states that it provides some defaults if you are doing :gen-class.

didibus02:09:43

Oh, I see. Ya was looking at the gen-class docs

donyorm07:09:56

hey everyone

jimmy09:09:12

hi guys, is there any way we can set env variable in repl ?

hans09:09:32

I'd say the best way to do that is when you're calling the external program that needs to see the environment variable.

hans09:09:50

You can't change an environment variable in your parent process, if that is what you hoped you could do.

hans09:09:32

https://clojuredocs.org/clojure.java.shell/sh has an :env argument that you can use to pass the environment that you'd like to set up.

jimmy09:09:32

yeah, but that env would only apply for the sub process within the repl, am I correct ?

hans09:09:09

Correct.

hans09:09:53

If you want to set your parent process' environment, you'll have to hack around. A common way is to use the shell's eval command and print the environment variables to stdout.

jimmy09:09:26

hmm, that's interesting. I will try it out, thanks

jimmy09:09:48

My problem is quite small, I can solve it with binding, it's good to know this trick

selfsame14:09:10

whats the clojure notation for 10^23, 10e23?

chris14:09:30

same as in java, 1.0E24

selfsame14:09:39

^ ok gotcha XeY is "X times 10 to the power of Y"

chris14:09:11

yep, that’s what you’re asking about right, scientific notation, not general exponents

selfsame14:09:25

yep, thanks!

rkosenko15:09:14

Is there any standard macros/function for #(func2 (apply func1 %&)) ? Something like (wrap func1 func2) ?

rkosenko15:09:00

Thanks, it's called comp.

spacepluk16:09:24

how can I turn a lazy-seq into an input-stream?

spacepluk16:09:40

I'm streaming the results of a jdbc query with a lazy-seq and I want to wrap that with an input-stream so I can upload to s3 with amazonica, but I can't figure out what's the best way to do that.

gordon17:09:28

@spacepluk Take a look at https://github.com/ztellman/byte-streams - specifically, the first mention of to-input-stream in the README looks like what you're after

spacepluk17:09:47

@gws that looks great! thanks!

grav20:09:35

clojure.data.xml has suddenly begun adding shortcut namespaces, like <a:foobar>…</a:foobar> instead of just <foobar></foobar>. I haven’t upgraded the version (`[org.clojure/data.xml "0.1.0-beta1”]`)

grav20:09:47

Any clues as to why?

hiredman20:09:40

check lein deps :tree

hiredman20:09:01

it looks like that changed between beta1 and beta2, so for some reason you are getting beta2

grav20:09:28

Yes … very weird

hiredman20:09:20

you can end up with some unexpected transitive dependency behavior, the easiest thing is to look at the deps :tree result, and add some :exclusions. if you specify the exact version you want as a direct dependency that should override any transitive dependency.

hiredman20:09:28

if data.xml is a dependency of anything you depend on, and any of your dependencies are aot compiled, that can lead to wonkiness too

grav20:09:42

Seems explicitly depending on beta2 fixes it … which makes me even more puzzled, since it’s been working fine with beta1

grav20:09:09

@hiredman Ok. I’ll see of there’s anything else depending on it

mccraigmccraig21:09:53

@grav i always set :pedantic? :abort which forces you to explicitly deal with any ambiguities in the set of transitive dependencies (or lein borks)