Fork me on GitHub
#clojure-europe
<
2024-02-14
>
Mario Trost06:02:15

Good morning everyone! (today’s task: removing a future and a memoize that we added last week. Both aren’t really necessary.)

reefersleep21:02:04

(comp forget past)

🙌 1
thomas07:02:32

Good morning!

synthomat08:02:45

good morning!

schmalz08:02:51

Morning all.

pez08:02:53

God morgon! I’m between Oslo and Bergen.

❤️ 2
thomas09:02:53

great view

reefersleep21:02:03

That's really beautiful :melting_face:

pez22:02:33

Bergen is quite breathtaking too.

maleghast08:02:12

madainn mhath :flag-scotland:

maleghast09:02:04

This was yesterday afternoon / evening in Glen Arklet - I had to grab a camera with that sky…

❤️ 6
😍 3
genRaiy09:02:39

wonderful shot. Kudos 🌹

maleghast09:02:35

Thx very much 😊

thomas10:02:04

I like the way you made it monochrome. very dramatic

👍 1
genRaiy11:02:05

good morning - YIL that this is fine

(defn a [_ _]
  _)
=> #'user/a
(a 1 2)
=> 2
:_)

😆 5
thomas12:02:16

It works as implemented 👍

borkdude12:02:44

there's also a clj-kondo rule called "used-underscored-binding" which is off by default

genRaiy13:02:54

why is it off by default? I've never seen it used for realz

borkdude13:02:43

because only critical things are on by default (and those that are not critical were on by default in the early days)

genRaiy13:02:35

ok, no biggie. I think any code review would this code

Ben Sless14:02:41

Task failed successfully

😂 4
teodorlu15:02:42

I’ve heard that code uses too many CPU cycles, and this seems like an excellent way to shave off some bytes! 😁

slipset07:02:40

Out of curisosity, what were you expecting to happen? I see a couple of options • compiler says can’t have multiple params with same name. • compiler chooses to assign to the first paramter • @U064X3EF3 showing up on your door, hit you across the head and says “Don’t do that!”

genRaiy08:02:51

I thought the semantic of is ignore, so I was assuming that the compiler would tell me that I can’t refer to an ignored value. But of course it’s just a convention. Reflecting on it, I think the best case is that the compiler could reject it on the basis that it can’t disambiguate the . Alex did actually pop up on the feed for apropos after we talked about that :)

Alex Miller (Clojure team)13:02:27

There is no semantic. Reused function parameter shadow previous. If you don’t like that, don’t do it. :)

genRaiy13:02:21

As Stu once said, Clojure is optimized for correct programs ™️

genRaiy13:02:34

I thought it was a joke but :man-shrugging::skin-tone-3:

Alex Miller (Clojure team)13:02:34

People frequently use _ for multiple ignored args - making this an error would break all those programs

genRaiy13:02:32

I only mean for the use not the [_ _ _]

borkdude13:02:32

I think there's two things here:

(defn foo [x x] x)
and (foo [_] _) both are valid clojure, but maybe not preferred from a style perspective which a linter could do something about. clj-kondo has a rule for the latter

genRaiy13:02:00

^^^ permitting the use of _ is odd? Well, imho at least

borkdude13:02:25

clojure never had any semantic for _ - it's just a user convention (in many programming languages)

reefersleep13:02:35

Yeah, it's just a name 🙂

genRaiy13:02:41

semantics and conventions are cousins ... and sometime their activities are borderline illegal

borkdude13:02:13

clojure doesn't prevent you from doing anything illegal, that's why we have linters ;)

reefersleep13:02:05

In fact, Clojure is very gray about what "illegal" is, in my view! Lots of "interesting" things you can do.

reefersleep13:02:57

Like ^:private being less of a locked door and more like a "please don't enter" sign

borkdude13:02:03

I like that very much about clojure ;)

genRaiy13:02:04

er, some things are illegal ... otherwise what was the point of spec? It depends on your definition of correct vs legal 🙂

borkdude13:02:39

the underscore stuff isn't part of the fn spec, so there's your answer ;)

reefersleep13:02:08

Sure, sure. Like, you can easily write code that the Reader won't read. In that sense, there's an endless amount of locked doors.

reefersleep13:02:24

Missing parens and so on

borkdude13:02:06

The fun thing is that clojure lets us write some tooling. What else are you going to waste your life on? ;) https://github.com/borkdude/edamame?tab=readme-ov-file#fix-incomplete-expressions

🤓 2
genRaiy13:02:03

this thread 😛

2
Alex Miller (Clojure team)13:02:32

Some things are invalid, some things are undefined but with observable behaviors. The example thread is not any of those: _ is a valid name, and repeating param names shadows previous (same as let). Everything else flows from that.

borkdude16:02:10

btw just found this related issue in the clj-kondo backlog: https://github.com/clj-kondo/clj-kondo/issues/1732

borkdude16:02:34

perhaps a new rule :same-named-param or so would be good

upvote 1
borkdude16:02:52

(better name suggestions welcome)

genRaiy16:02:07

fwiw I think returning or otherwise using _ or for that matter _x in the body should be warned cos it's likely a mistake, and kondo could highlight it without disturbing the compiler's flow.

borkdude16:02:28

this is already a linting rule called :used-underscored-binding - these are two separate things

1
borkdude16:02:01

I'm just referring to using same named function arguments in general (not related to underscores)

genRaiy16:02:41

ok ... I understand the distinction, I wasn't aware of the existing rule

otfrom16:02:09

getting a round of keybase spam