On Fri, Aug 02, 2002 at 12:33:07PM +0100, josh singer wrote: > Hi folks, > > A question: > > I'm considering having some "sanity checks" in my ECLiPSe code, but I'd like > the ability to turn them off at compile time so that the deployed object > code is more efficient. A bit like an #ifdef in C. What are the options for > implementing such conditional compilation in ECLiPSe? Please find attached a pair of modules `debug' and `nodebug' which allow you to switch debugging code on/off statically on a per-module basis. Just wrap any sanity checks / diagnostics / whatever in a call to debugging/1, and import the relevant module: importing `debug' turns them on; importing `nodebug' turns them off. The debugging/1 wrapper is compiled away whenever possible. If you want to be able to turn debugging on and off dynamically, have a look at compile_term/1. You can use that to redefine a debugging predicate to either make the call or do nothing. Of course if you really wanted to get fancy you could have different categories of debugging which could be turned on/off dynamically on a per-module basis. But I leave that as an exercise for the reader. :) (If anybody seriously wants to try implementing this but needs some pointers, drop me a line...) Cheers, Warwick
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:15 PM GMT GMT