This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-14
Channels
- # ai (4)
- # babashka (4)
- # beginners (46)
- # biff (5)
- # calva (12)
- # clojure (6)
- # clojure-austin (13)
- # clojure-dev (27)
- # clojure-europe (62)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-spec (2)
- # clojure-uk (12)
- # clojurescript (10)
- # cursive (3)
- # datahike (26)
- # datalevin (9)
- # datomic (7)
- # gratitude (4)
- # honeysql (9)
- # hyperfiddle (12)
- # instaparse (2)
- # lsp (65)
- # membrane (7)
- # missionary (2)
- # off-topic (8)
- # polylith (33)
- # portal (7)
- # quil (1)
- # re-frame (4)
- # reagent (18)
- # releases (3)
- # ring (3)
- # spacemacs (2)
- # specter (4)
Good morning everyone!
(today’s task: removing a future
and a memoize
that we added last week. Both aren’t really necessary.)
#bliss
That's really beautiful :melting_face:
This was yesterday afternoon / evening in Glen Arklet - I had to grab a camera with that sky…
Thanks @U052852ES
Morning!
good morning - YIL that this is fine
(defn a [_ _]
_)
=> #'user/a
(a 1 2)
=> 2
:_)there's also a clj-kondo rule called "used-underscored-binding" which is off by default
because only critical things are on by default (and those that are not critical were on by default in the early days)
I’ve heard that code uses too many CPU cycles, and this seems like an excellent way to shave off some bytes! 😁
hahahahaha
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!”
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 :)
There is no semantic. Reused function parameter shadow previous. If you don’t like that, don’t do it. :)
People frequently use _ for multiple ignored args - making this an error would break all those programs
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 latterclojure never had any semantic for _
- it's just a user convention (in many programming languages)
Yeah, it's just a name 🙂
semantics and conventions are cousins ... and sometime their activities are borderline illegal
clojure doesn't prevent you from doing anything illegal, that's why we have linters ;)
In fact, Clojure is very gray about what "illegal" is, in my view! Lots of "interesting" things you can do.
Like ^:private
being less of a locked door and more like a "please don't enter" sign
er, some things are illegal ... otherwise what was the point of spec? It depends on your definition of correct vs legal 🙂
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.
Missing parens and so on
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
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.
btw just found this related issue in the clj-kondo backlog: https://github.com/clj-kondo/clj-kondo/issues/1732
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.
this is already a linting rule called :used-underscored-binding
- these are two separate things