Fork me on GitHub

Pathom updated docs (thanks to @tony.kay) are live, many sections got a lot of improvement! A highlight to the new GraphQL integration docs:

👍 12
🚀 16
👏 16

Clojurists Together has finished our latest survey and have a list of focus areas for our next funding round: Encourage the projects that you depend on to apply for funding. If you have any questions about applying, please get in touch here or via any of the other places you can find me 🙂. Applications close 9th October

🙌 16
clj 28

I've seen this in the code, and wanted to know the reasons for it being this way. I was surprised that keywords can take sets, and even more surprised that they can only take IPersistentSet or ITransientSet whereas java.util.Map is supported.


Is there an idiomatic use for applying a keyword to a set?


@U4844LY6A (Clojure) sets are associative on their keys -- like a map whose values are the same as their keys -- so you can call "get" on them. Java sets don't have that associative lookup -- only a "contains" operation. That would be my understanding of why you can lookup keywords in (Clojure) sets but not Java sets.


(and arrays are associative on their indices -- so, again, it makes sense to allow lookup "get" on those)


Does that make sense?


Having get on maps, sets and arrays makes sense to me.


It would make more sense to me if keyword application either supported java sets or not supported any sets at all. And of course supporting keyword application on vectors makes no sense at all.


The fact that java sets don't have a get operation seems like a weak excuse for not supporting them.


But I'm not complaining, since I don't have any use for applying keywords to sets at the moment. 🙂


Clojure is based on abstractions. map, set, and vector are associative in Clojure, hence should all support get. Java's Map is associative, Java's Set is not.


Re: keyword on vector -- vectors are associative on their index so, no, Clojure does not support keyword lookup on them. (kw coll) is "the same" as (coll kw) which is "the same" as (get coll kw) and for vectors (coll ix) is the shorthand.