Warning: ob_start(): non-static method wpGoogleAnalytics::get_links() should not be called statically in /home/w01fe/w01fe.com/wordpress/wp-content/plugins/wp-google-analytics/wp-google-analytics.php on line 259
A Blog. » 2009 » April

Archive for April, 2009

Quick tip for debugging & profiling Clojure code with multimethods

Debugging and profiling Clojure code with multimethods can be a pain, since methods show up as anonymous functions in stack traces and profile results. When you’re debugging you at least get a line number, but if you’ve loaded your code in a nonstandard way (i.e., with SLIME) or you’re using a profiler like YourKit, you don’t get this information. Then, the only clue you have to figure out what my.long.namespace$fn_12312 represents is context — who called it, and who it calls.

Similar issues exist for anonymous functions, which some time ago I realized you could give names by using (fn name [args] & body). What I didn’t realize is the same is true of multimethods. By simply using (defmethod multifn dispatch-val *name* [args] &body), you can give each instance of a multimethod a unique name, which will show up in stack traces and profile results.

Comments (2)