Clojure

Details

Type:
Defect

Status:
Closed

Priority:
Minor

Resolution:
Declined

Affects Version/s:Release 1.3

Fix Version/s:
None

Component/s:
None

Labels:

None

Patch:

Code and Test

Description

The result of (bean obj) throws a NullPointerException when passed in a key that doen't exist. I think instead it should return nil to be consistent with maps and records - or at least the error message should be more explicit.

Activity

Beans aren't maps, and without any discussion of motivation it isn't clear that this change is an improvement.

If bean was more consumer-friendly, people might use it in production more often. Don't. Reflection is slow. If there is a motivating use case other than REPL exploration for converting beans to maps, let's design something more performant targeted to that case.

Stuart Halloway
added a comment - 05/Apr/11 8:46 PM Beans aren't maps, and without any discussion of motivation it isn't clear that this change is an improvement.
If bean was more consumer-friendly, people might use it in production more often. Don't. Reflection is slow. If there is a motivating use case other than REPL exploration for converting beans to maps, let's design something more performant targeted to that case.

The proxy returned by (bean) performs a bare invocation on the getter method without checking if it exists first. Fixed the bug by adding a long-hand constantly as the missing value for the map fetch. (constantly is not defined yet when core_proxy is read.)

Also renamed the property map defined in bean to 'propmap' instead of 'pmap' to avoid ambiguity with clojure.core/pmap

Alexander Redington
added a comment - 25/Mar/11 9:51 AM The proxy returned by (bean) performs a bare invocation on the getter method without checking if it exists first. Fixed the bug by adding a long-hand constantly as the missing value for the map fetch. (constantly is not defined yet when core_proxy is read.)
Also renamed the property map defined in bean to 'propmap' instead of 'pmap' to avoid ambiguity with clojure.core/pmap