You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Collections section should elaborate on when set literal syntax is not appropriate, i.e. when the values in the set are not compile time constants.
There's been recent discussion on this on the Clojure ML[1] and it's spawned a wiki page[2] The consensus is (AFAICT) that if there's a possibility of duplicate values the constructor functions are preferred over literal syntax. There's further discussion on whether duplicates are appropriate in literals, but I don't think that's worth adding here.
I propose adding the following
Only use set literal notation when set values are compile-time constants
; good
(hash-set (func1) (func2))
; bad, will throw exception if (func1) == (func2) at runtime.
#{(func1) (func2)}
The Collections section should elaborate on when set literal syntax is not appropriate, i.e. when the values in the set are not compile time constants.
There's been recent discussion on this on the Clojure ML[1] and it's spawned a wiki page[2] The consensus is (AFAICT) that if there's a possibility of duplicate values the constructor functions are preferred over literal syntax. There's further discussion on whether duplicates are appropriate in literals, but I don't think that's worth adding here.
I propose adding the following
[1] https://groups.google.com/forum/?fromgroups=#!topic/clojure/AG667ACBd3I
[2] http://dev.clojure.org/display/design/Allow+duplicate+map+keys+and+set+elements
The text was updated successfully, but these errors were encountered: