(Non) Nesting block comments

yigal chripun yigal100 at gmail.com
Wed Jul 22 01:15:55 PDT 2009


Michel Fortin Wrote:

> On 2009-07-21 05:31:13 -0400, Michiel Helvensteijn 
> <m.helvensteijn.remove at gmail.com> said:
> 
> > Robert Jacques wrote:
> > 
> >> Well /* */ are excellent for toggling code sections. I tend to use
> >> constructs such as // */ or  //* or /*/ which allows me to turn on of off
> >> blocks with often a single key stroke. Using /+ +/ means I have to Add
> >> /++/ and remove /++/ each time I want to activate or deactivate a code
> >> block.
> > 
> > Why? I believe that /++/ works exactly like /**/ in that regard. Doesn't it?
> > 
> > //+
> > code that can be turned off by removing the first /
> > //+/
> 
> I'm pretty sure he meant comment out a signle line at the top, not 
> both, like this:
> 
> 	/*
> 	A
> 	/*/
> 	B
> 	/**/
> 
> With this, you compile B while A is in a comment. Add "/" at the start 
> of the first line and you compile code A while B is now in commented 
> out.
> 
> 
> -- 
> Michel Fortin
> michel.fortin at michelf.com
> http://michelf.com/
> 

IMHO, this is an ugly trick. it's less readable IMO and it just saves a cuple keystrokes. readability is more important than that.
more over, this is completely unneeded (unless you program in notepad) since even the simplest of the (programmer) text editors has a shortcut to comment/uncomment a block of code. For instance, in Eclipse it's Ctrl+Shift+/

-- yigal



More information about the Digitalmars-d mailing list