Fork me on GitHub
#clojure-europe
<
2022-12-08
>
grav06:12:54

Morning!

reefersleep08:12:45

Good morning 🙂

ray08:12:19

Good morning

🌳 6
😯 2
chef_kiss 1
lemontea09:12:52

gooooood morning

thomas09:12:00

Morning!!!!

lemontea09:12:50

Fashion trend question (may be a bit silly): When you do a (ns ... (:require [clojure.string :as _])) , what alias do you usually use? ClojureDocs use str, but there’s already a str function in clojure.core. string works, but seems to be too long…

reefersleep09:12:46

I’ve seen/used str, s and string. I think string is the most solid - str (kind of) shadows, as you say, and s is too short. I’ve learned not to worry as much as I used to about it 🙂 But it would be neat if there were “standards” so that you could adhere to them without a second thought.

lemontea09:12:45

yes, I believe there is no absolute right answer in this case, and that’s why it is “Fashion”

lemontea09:12:18

(Let’s just hope it doesn’t change completely every six months 😂)

Jakub Holý (HolyJak)10:12:20

str. There is no shadowing b/c namespace and fns are in different "domains".

☝️ 1
Jakob Durstberger10:12:34

I agree with Jakub. I’d use str as I think it is fine to have a namespace and a function having the same name. Clojure knows the difference.

lemontea10:12:10

oh that’s a good point okay!

lemontea10:12:38

(btw, “Jakub” and “Jakob” @@ )

lemontea10:12:09

(are the names related in some way? or are they commonly used names?)

reefersleep10:12:02

I know that there’s no technical shadowing, but I still prefer not having two things with the same name, if it can be trivially avoided.

lemontea10:12:29

oh @U0AQ3HP9U you stole my line 😅

lemontea10:12:19

I do think that avoiding “collision that ain’t technically a collision” is more for benefit of beginners who may not know the details of clojure in and out

lemontea10:12:42

(although in a coding guideline that fact should probably be mentioned somewhere to clear the air)

slipset10:12:36

Since I work with @jakub, str, but ai should also plug that we use superstring rather than clojure.string

wow 1
reefersleep10:12:23

#solidarity :fist:

Jakub Holý (HolyJak)10:12:45

Jakob and Jakub both stem from the same old Hebrew name

👀 1
lemontea10:12:59

@U0522TWDA that’s a TIL… you learn something new everyday, I suppose 👍

lemontea10:12:20

@U04V5VAUN wait, that picture in the github readme of superstring… looks like some super-advanced pure math (I’m a math major) - algebraic geometry or some string theory stuff?

lemontea10:12:09

(I vaguely remember the same/similar photo hang on the wall of the math department I studied in)

slipset10:12:33

I think that’s an intentional pun or something.

lemontea10:12:29

ya that’s probably it. Hope it’s not an overkill 😀

robert-stuttaford10:12:29

and we have a kondo rule that warns if you use anything else!

otfrom11:12:18

@U0509NKGK what does that look like? (I'm thinking it might be handy to keep some aliases consistent across namespaces and projects)

robert-stuttaford11:12:02

kondo is flippin great!

2
lread14:12:22

I just use whatever the code base I'm working on uses. When writing new code, I`ve typically used string but I'm not married to it and am also totally ok with str.

simongray14:12:55

I use str because the docstring for clojure.string literally requires it as str .

simongray14:12:09

>

It is poor form to (:use clojure.string). Instead, use require
> with :as to specify a prefix, e.g.
> 
> (ns your.namespace.here
>   (:require [clojure.string :as str]))

robert-stuttaford15:12:58

our team argued about it about once a year until someone lost their temper with it and added a kondo rule and refactored all the code to match it 😂

😖 1
otfrom15:12:34

I instituted a rule in my company that I resolve all bikeshedding issues.

lread15:12:20

There ain't no bikeshedding on this ranch, if you wanna bikeshed, you come bikeshed me!

Jakub Holý (HolyJak)10:12:17

Morning from 🩸 giving center!

👍 1
reefersleep10:12:08

Did you get a cookie?

reefersleep10:12:51

Or is that an American thing?

reefersleep10:12:52

:saluting_face:

Jakub Holý (HolyJak)10:12:27

It is not the only reason I keep coming there.. 😅

thomas10:12:34

I would consider it for a chocolate.... it is just that they don't want my blood (and I'd probably faint as well)

dharrigan12:12:51

I tried to give blood once (in my yoof) and I nearly passed out, that was before they even took blood!

Jakub Holý (HolyJak)14:12:12

Avoid Transylvania then 🧛

slipset12:12:39

So, I got this idea while listening to Software Disrupted about an inferred type system: My preferred type system is basically coding in Clojure as today, but then when I’m “done” or I feel certain about my data structures, it would be nice to sprinkle som types on it. But that retro fitting process is a bit cumbersome. But what if you could do something like:

(s/def ::user any?)

(s/fdef foo :args (s/cat :user ::user))
(defn foo [user] ...)
And then by magic ie static analysis have a compiler figure out what constitutes a user. The trick of course being that you have many fns which take a user as an arg, and that those fns in turn pass the user around to other fns which may or may not be speced. So for instance if I said in my foo fn:
(defn foo [{:keys [:name] :as user}]
   (println "This user has name" name "and email" (:email user)))
The inferring type system would understand that the user spec should contain both a :name and an :email

borkdude13:12:51

This is kind of what's possible with malli + clj-kondo

borkdude13:12:39

clj-kondo has a simple type system and malli is able to spit out the configuration for that, based on its own format

reefersleep14:12:00

Ask and ye shall receive 🙏

simongray14:12:03

Very cool, Borkman!

lread14:12:57

good morning!