Tuesday, February 15, 2005

Contributing to the Pool

When discussing an open society, one thing that doesn't get quite as much emphasis as it should is that, if everyone can draw on the creative commons, then everyone should at least try to contribute.

This is called trade. It isn't mandatory to do so, of course, but it seems to be the right thing to do and, no, I haven't been particularly giving.

So, a little something of my own for any programming geeks passing through...

When debugging a program, it is occasionally useful to isolate a section of code, so it can be determined whether or not that is where the problem is. Alternately, you may wish to toggle debugging code on or off

Whatever, a common way to do this is to wrap the code in a comment block thus:
/*
if (itFeelsGood)
{
DoIt();
}
*/
All well and good. However, a problem arises when the blocked code is large, or if you want to toggle a useful but expensive debugging feature: you have to continuously remove and insert both the start and end of the comment block, which is both tedious, and can cause some obscure compilation errors.

The trick I've found is that, by masking the comment blocks by means of a line comment, you can toggle the block off and on by a single key stroke.

Now you see it:
//*
if (itFeelsGood)
{
DoIt();
}
//*/
and now you don't:
/* <-- deleted one slash
if (itFeelsGood)
{
DoIt();
}
//*/
I hope you find it useful.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home