I think it's important that Clojure be good at exploring Java libraries. Helpful and correct error messages are important for this. I often go looking for a function at the REPL, like so:
user=> substring java.lang.Exception: Unable to resolve symbol: substring in this context (NO_SOURCE_FILE:0) user=> substr java.lang.Exception: Unable to resolve symbol: substr in this context (NO_SOURCE_FILE:0) user=> subs #<core$subs__5256 clojure.core$subs__5...@37699720> Aha! It's 'subs'. This doesn't work with Java methods though. user=> (.substringXXXX (String. "foo")) java.lang.IllegalArgumentException: No matching field found: substringXXXX for class java.lang.String (NO_SOURCE_FILE:0) user=> (.substring (String. "foo")) java.lang.IllegalArgumentException: No matching field found: substring for class java.lang.String (NO_SOURCE_FILE:0) You've got to supply the right arguments else you get no hint that you have found a method: user=> (.substring (String. "foo") 1) "oo" Same thing with static methods: user=> (String/valueOf) java.lang.NoSuchFieldException: valueOf (NO_SOURCE_FILE:89) Not true. And there's no hint that I'm any closer to a real method than if I'd tried gibberish: user=> (String/valueOfXXX) java.lang.NoSuchFieldException: valueOfXXX (NO_SOURCE_FILE:88) Here's the correct usage: user=> (String/valueOf 9) "9" On Wed, Jun 24, 2009 at 9:38 PM, Mark Addleman<mark_addle...@bigfoot.com> wrote: > > Searching through this forum, I found many posts relating to improving > Clojure's error messages. I stumbled across one where Rich makes a > plea for concrete suggestions to specific cases. I'm very sympathetic > to that, so I'd like to start a thread of specific coding errors that > I've run across where I've felt the error messages could be improved. > > (*) Improperly specifying a map, e.g. "{:a 1 :b}" yields an array out > of bounds exception. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---