Improving Clojure's Error Messages with Grammars - Colin Fleming





The interactive transcript could not be loaded.


Rating is available when the video has been rented.
This feature is not available right now. Please try again later.
Published on Nov 16, 2015

One of the most frequent complaints from new users of Clojure is the error messages. But many of the error messages that users are faced with are not actually errors from the core language at all but instead surface from macro parsing code. This parsing code is often brittle, difficult to write and can produce truly awful errors.

Cursive is a Clojure IDE which works from unexpanded source. It uses Parsing Expression Grammars to parse macro forms, which makes the parsing code much quicker to write and also dramatically increases its composability and reusability. Additionally this allows much better error reporting. Syntax errors can be identified at the point the error occurs with much friendlier messages. Achieving better error reporting requires little extra work by the developer. Cursive can use this information to mark syntax errors in the editor and provide information about what was expected at the error point.

I'll show a lot of examples of the grammars that Cursive uses and also the code that uses them. I'll also discuss the benefits from using this technique for more general macro parsing - I now believe we should parse all macros this way.

About the speaker: Colin is the developer of Cursive. He has programmed things for a long time now, and came to Clojure from Java via Scheme a few years ago. When he's not hacking on Cursive he's mostly waiting for his daughter to get old enough to program robots together.


When autoplay is enabled, a suggested video will automatically play next.

Up next

to add this to Watch Later

Add to

Loading playlists...