Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: Release 1.3, Release 1.4
-
Fix Version/s: Release 1.6
-
Component/s: None
-
Labels:None
-
Patch:Code
-
Approval:Ok
Description
1.3 removed the metadata slot on most functions, and made .withMeta return a new wrapping function that provides metadata. This changes the way functions with metadata print: instead of #<user$eval595$fn_596 user$eval595$fn_596@3d48ff04> we now see #< clojure.lang.AFunction$1@581de498>. I might argue that we should "lie" and print the class of the original wrapped function since it's more useful than AFunction$1, but that's debatable. The two things I propose changing are:
- When *print-meta* is true, we should print the metadata map for functions. That nothing prints implies there is no metadata, which can make it difficult to track down bugs related to metadata on functions.
- Remove the errant space at the front of the printed representation of functions with meta, changing #< clojure.lang.AFunction$1@581de498> to #<clojure.lang.AFunction$1@581de498>. The cause of this issue is that .getSimpleName on an object with an anonymous class returns "", and we print that followed by a space and its .toString. My fix is to omit the extra space if the class has no simple name; this would cause instances of other anonymous (non-function) classes to print more nicely as well.
If it would be desirable to print the class of the original "wrapped" function, then I can easily add another patch for that.
clj-908-Print-metadata-and-anonymous-classes-better-patch2.txt dated May 19, 2012 only has context line changes from the previous one, 0001-Print-metadata-and-anonymous-classes-better.patch dated Jan 10, 2012. The previous one no longer applies cleanly to the latest master, while the new one does.