Fork me on GitHub
#clojure
<
2022-05-27
>
grounded_sage09:05:16

When using tools build like so clj -T:build build-fn . How do I include extra aliases? I expected it to be like clj -A:backend -T:build build-fn or clj -T:backend:build build-fn but these appear to be incorrect.

borkdude10:05:57

@grounded_sage Perhaps you intend to make a basis with :aliases [:backend] instead? Or do you intend to use code from the backend for the build, rather than making a jar/uberjar/etc from the backend code?

grounded_sage10:05:39

Oh basis looks like it might be what I am looking for.

borkdude10:05:49

I recommend going through the tools.build tutorial on http://clojure.org

borkdude10:05:11

Although I now see that :aliases isn't explicitly mentioned there

grounded_sage10:05:54

Yea.. I frequently consult the docs and I was looking at other repos to see if there was anything that appeared to do what I want.

grounded_sage10:05:08

Also I usually skim a lot as well so sometimes I miss things

grounded_sage13:05:26

Basis did the trick. Thanks!

👍 1
Alex Miller (Clojure team)12:05:05

Are you including the alias to change the deps available for the build tooling or for the basis used in the build? If the latter, in your build script when calling b/create-basis, you can pass :aliases […]

Alex Miller (Clojure team)12:05:18

If the former, you should be able to pass it with the -T like you have at the beginning

pinkfrog14:05:10

Is *ns* only meaningful inside a repl?

sansarip15:05:44

It’s useful whenever you need the current namespace, repl or not. One caveat, however, is that it cannot be used directly (at runtime) in cljs like it can in clj

pinkfrog12:05:39

In clj, what’s the meaning of current namespace when the function is invoked NOT in a repl?

sansarip14:05:35

Quite a philosophical question you’re asking 😂 I don’t know how to answer that question specifically! Have you ever defined a namespaced keyword like so ::my-keyword? If so, then you’ve used the current namespace -albeit at compile time. Surely, it’s not inconceivable that there could be other [perhaps similar] scenarios where the current namespace (at runtime) would have meaning?

pinkfrog00:05:31

I find the *ns* a bit confusing outside of the context of a repl.

dpsutton16:05:39

I’m trying to reify java.beans.PropertyChangeListener which has a single method propertyChange [_ ^java.beans.PropertyChangeEvent evt] which returns void. But Clojure of course always returns a value so I’m getting the error > Mismatched return type: propertyChange, expected: void, had: java.lang.Object I’m not sure how to wrap this so it returns nothing. Does anyone know how to accomplish this?

dpsutton16:05:47

I see > If the method has a void return type, the value of the expression will be nil. from the interop reference https://clojure.org/reference/java_interop but i am returning nil

connection=> (-> (data-source)
                 (.getConnectionPoolDataSource)
                 (.addPropertyChangeListener
                   (reify java.beans.PropertyChangeListener
                     (propertyChange ^void [_ ^java.beans.PropertyChangeEvent evt]
                       (tap> {:prop-name (.getPropertyName evt)
                              :old-value (.getOldValue evt)
                              :new-value (.getNewValue evt)
                              :str (str evt)})
                       nil))))
Syntax error (IllegalArgumentException) compiling reify* at (REPL:41:20).
Mismatched return type: propertyChange, expected: void, had: java.lang.Object
connection=> 

dpsutton16:05:51

i had tried to typehint the arg vector but seems it has to go on the method name

(^void propertyChange [_ ^java.beans.PropertyChangeEvent evt]

hiredman17:05:04

Clojure 1.10.3
user=> (reify java.beans.PropertyChangeListener
  (propertyChange [_ evt]
    (println "foo")))

#object[user$eval136$reify__137 0x726a6b94 "user$eval136$reify__137@726a6b94"]
user=> user=> (reify java.beans.PropertyChangeListener
  (propertyChange [_ ^java.beans.PropertyChangeEvent evt]
    (println "foo")))
Syntax error (IllegalArgumentException) compiling reify* at (REPL:1:1).
Mismatched return type: propertyChange, expected: void, had: java.lang.Object
user=>
user=>

dpsutton17:05:35

oh interesting. since i type hinted i gave conflicting information? And the compiler could figure out the unambiguous types if i hadn’t attempted to help?

Alex Miller (Clojure team)17:05:18

You shouldn't need to do anything for this to work

dpsutton17:05:56

i see. once again learning rely on the reflection warning and don’t guess

dpsutton17:05:00

thanks to yall

rgm18:05:40

Does anyone have any experience with hashicorp consul/nomad? I'm looking for something like a luminus template deploy example, where a simple clj app has to connect to a postgres db.

dpsutton21:05:59

is there a good way to loop over some socket repls from the command line?

echo "(+ 1 1)" | nc localhost 6000
this works but leaves the repl connected. I’m hoping to just capture the output and continue looping but I’m not quite sure how to send an end of input I guess?

dpsutton21:05:39

using -d it seems this is sending en EOF > (debug) EOF Received from stdin! (removing from lookups..)

nivekuil21:05:58

-W or -w? And -q should make it exit after EOF

dpsutton21:05:02

-W and`-q` gives invalid option (this is on an m1 mac). -w gives an invalid wait-time: localhost error

nivekuil21:05:56

-w takes a timeout value, bit of a hack but idk mac

dpsutton21:05:56

i gave it a 1 and it seemed to have no change in behavior

seancorfield21:05:31

echo :repl/quit perhaps?

hiredman21:05:13

the version of netcat I have installed (ncat from nmap) works like what you want without doing anything extra

hiredman21:05:32

% echo '(+ 1 2)' | nc localhost 9457
user=> 3
user=> %

dpsutton21:05:46

:repl/quit works. thanks @U04V70XH6. i should have thought about that. I’m confused why this is weird on mac. i’m assuming you are on some linux hiredman?

hiredman21:05:07

it is weird on a mac because apple never updates the base utils

hiredman21:05:29

so who knows how old the version of netcat they ship is

hiredman21:05:07

if you look online you can find people complaining about it, and suggesting installing nmap from homebrew to get ncat

hiredman21:05:25

(but yeah, I am on linux)