FWIW, this is the kind of problem that paredit mode in Emacs eliminates almost entirely.
On Thu, Jun 25, 2009 at 11:14 AM, Rich Hickey <richhic...@gmail.com> wrote: > > > > On Jun 25, 9:36 am, Mark Addleman <mark_addle...@bigfoot.com> wrote: > > On Jun 25, 4:26 am, Rich Hickey <richhic...@gmail.com> wrote: > > > > > > > > > > > > > On Thu, Jun 25, 2009 at 7:03 AM, James Reeves< > weavejes...@googlemail.com> wrote: > > > > > > On Jun 25, 10:02 am, James Reeves <weavejes...@googlemail.com> > wrote: > > > >> Here's one that regularly confuses me: > > > > > >> (prn [10) > > > > > >> => java.lang.Exception: Unmatched delimiter: ) > > > > > >> Ideally the exception should correctly report the type of unmatched > > > >> bracket. In this case: > > > > > >> => java.lang.Exception: Unmatched delimiter: ] > > > > > > I've just realised I've made a mistake. The error message is not > > > > complaining that there is a parenthesis missing; it is complaining > > > > that an ending parenthesis has no matching start parenthesis. > > > > > > So this is an technically accurate error message, but perhaps not the > > > > most intuitive, as a user is more likely to miss off an ending > bracket > > > > than a starting one. A better error message might be: > > > > > > => java.lang.Exception: Missing delimiter: ] > > > > > But it doesn't know when it sees the ) that ] is missing, it might not > be: > > > > > (prn [10)] > > > > > i.e. the ) has nothing to do with the [, there might not even be a > > > pending aggregate: > > > > > user=> ) > > > java.lang.Exception: Unmatched delimiter: ) > > > > > Rich > > > > In your example, couldn't the parser know that when it sees the ), > > something has gone wrong? Maybe it's due to my IDE's lack of > > sophistication, but I find my paren/bracket/brace problems are almost > > always around closing them properly (hey, that's punny!) so it would > > help me if the error message indicated that it saw ) but expected ]. > > > > It does know when it sees the ')', and reports it then. But what > exactly has gone wrong (beyond the ')' has no partner) is subjective. > Another example: > > (let [x map inc nums)] ...) > > Clearly the message: "java.lang.Exception: Missing delimiter: ]" would > not be helpful here. > > This seems to me an edit-time bug best fixed using an editor with > proper matching support. > > Rich > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---