Details
-
Type:
Defect
-
Status:
Closed
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: Release 1.2
-
Component/s: None
-
Labels:None
Description
Current behaviour:
user=> (defrecord Foo [size seq]) user.Foo user=> (:size (Foo. 42 :b)) 2 user=> (:seq (Foo. 42 :b)) ([:size 42] [:seq :b])
Patch attached, with a test. Thoughts:
1. filtering on base-fields would probably be cleaner, but it looks like (class ~'gtarget) isn't fully formed at that point?
2. this results in a .valAt lookup for any fields that collide with no-arg methods implemented by the defrecord's class. That's unavoidable AFAICT.
3. The best solution would be to disambiguate field access vs. no-arg method invocation, i.e. have a variant of (. obj field) that would be specifically for field access (which is very occasionally needed elsewhere as well). This would nullify # 2.
Converted from http://www.assembla.com/spaces/clojure/tickets/329
Attachments:
no-arg-defrecord-fields.diff - https://www.assembla.com/spaces/clojure/documents/aLddOwvi8r35mPeJe5cbLr/download/aLddOwvi8r35mPeJe5cbLr