[CLJ-736] Docstring of defrecord (and =) does not correctly describe equality behavior for records. Created: 09/Feb/11 Updated: 01/Mar/13 Resolved: 02/Sep/11 |
|
| Status: | Closed |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.2, Release 1.3, Release 1.4 |
| Fix Version/s: | Release 1.3, Release 1.4 |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Jason Wolfe | Assignee: | Stuart Halloway |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Approval: | Accepted |
| Waiting On: | Stuart Halloway |
| Description |
|
http://groups.google.com/group/clojure/browse_frm/thread/eba691b38c45196b# The docstring of defrecord says it "will define type-and- Along the same lines, the docstring of = says "same as Java x.equals FWIW I think it would be more clear if the behavior for = and .equals were the same in this respect, but in any case the implemented behavior should be properly documented. |
| Comments |
| Comment by Stuart Sierra [ 06/Jun/11 9:37 AM ] |
|
Also discussed at https://groups.google.com/d/topic/clojure/e6UhXVny8Xc/discussion Per Rich, "The policy is: = includes the type and .equals doesn't. In this way records can still be proper j.u.Maps and = remains most useful for records (e.g. including type)." |
| Comment by Jason Wolfe [ 06/Jun/11 11:25 AM ] |
|
On a related note: Regarding "hash maps and sets now use = for keys ... will use stricter .equals when calling through java.util interfaces": Note that "=" is actually stricter than ".equals" for record types currently, because it includes type information. This has important consequences for how (and whether) hash maps and sets actually obey the java.util interfaces. For instance, if (defrecord P []), ... what should (.get {(P.) 1 (Q.) 2} (Q.)) return? How about if we .get an element of a third type (R.)? |
| Comment by Aaron Bedra [ 28/Jun/11 6:36 PM ] |
|
Open question:
Non-issues:
|
| Comment by Aaron Bedra [ 19/Aug/11 11:34 AM ] |
|
Any thoughts on the open questions part Rich? |
| Comment by Stuart Halloway [ 02/Sep/11 9:37 AM ] |
|
I think the following is better: monospaced But I don't want to hold release for discussion, so bumping this to approved backlog for further bikeshedding. |
| Comment by Stuart Halloway [ 02/Sep/11 9:39 AM ] |
|
Better yet, let's just agreed on my prose and call this done. |