Fork me on GitHub
#clojure
<
2022-05-26
>
emccue00:05:26

Has anyone installed cljstyle from brew recently? I get the standard "we're Mac and you need to find the actual file and right click it since we don't know the developer"

Ertugrul Cetin07:05:01

Not brew but we (in our team) did not have any problem using installation script: https://github.com/greglook/cljstyle#installation-script-macos-and-linux

Nom Nom Mousse10:05:25

I want to create something like Python's __init__ files that make it easier to import stuff. My intention is to let users just do (:use [everclear.api]) instead of (:require [everclear.parse.create-user-ns :refer [defrule]]). Example:

(ns everclear.api
  (:require [everclear.parse.create-user-ns :refer [defrule]]))
However, if I try to do
(:require [everclear.api :refer [defrule])
I get the error message defrule not defined. defrule is a macro btw. How do I allow users to import stuff from api?

borkdude10:05:02

If you want to make an API namespace that just gathers functions from other namespaces, just write wrapper functions.

3
Nom Nom Mousse10:05:18

I considered that at first. Wrote a wrapper macro 🙂 🙏 Thanks for steering me back on the right path.

John Conti16:05:40

Asking for a friend..... Is there a substantive difference between writing a wrapper function or doing something like:

(ns api
  (:require [that.which.i.wrap :as to_wrap]))

(def crossed-beams? to_wrap/crossed-beams?)
I once used potemkin/import-vars but it confused some tooling. (I think clojure.tools.namespace that parses ns macros at the heads of files).

borkdude16:05:57

@U03E8292BBL Tooling which relies on static analysis won't see docstrings and arglists that way

thanks3 1
borkdude16:05:06

But if you don't care about that, then it's fine

pinkfrog14:05:42

Is the survey result for this year out or not?

Alex Miller (Clojure team)15:05:17

no, but it's in final stages of review

Patrick Brown15:05:50

Ummm, I’m doing something wrong? Does anyone know how to construct a keyword programatically that I can call against a map. I thought it would be simple, but I’m missing something. Here’s about what I’d like. Note, I’d like the namespace (get props ::component/keyword) Doesn’t work. (get props (keyword (str ":component/" k))

p-himik15:05:12

::stuff is a reader construct, not a runtime construct. You have to use a full namespace. Also, don't use : when constructing a keyword - it'll become a part of the name or namespace. And don't use string concatenation - keyword has another arity for specifying namespaces.

p-himik15:05:40

You can still use a namespace alias though, but it will be indirect:

(keyword (namespace ::component/-dummy-kw) k)

Patrick Brown15:05:42

cheers for the reply. I’m following you, but I’m not sure where to find the source so I can see this multi-arrity

Alex Miller (Clojure team)15:05:58

if you want to resolve the alias into a full ns, you can do that on the namespace mappings of course

Patrick Brown15:05:34

This is all very interesting. Thanks for the quick response. I’ve got it from here. CHEERS

tomekw16:05:01

Do you know any pure Clojure generic connection pool? Or should I just look at Apache Commons Pool? (https://commons.apache.org/proper/commons-pool/)

lukasz16:05:10

Using Commons Pool as a bit awkward but its def a good option, if you need a very robust solution. Otherwise a record with some internal state might be a simpler option

lukasz16:05:27

Also io.aleph.dirigiste might be worth looking at

tomekw21:05:35

Yes, I know: https://github.com/tomekw/hikari-cp 😉 I'm looking for something generic, like "any TCP connection" pool

tomekw21:05:50

Thx @U0JEFEZH6, dirigiste looks 👌

lukasz15:05:24

thanks for the heads up - we ended up not using for different reasons, but still - good to know :thumbsup: