[NTG-context] multiple line comments

Hans Hagen pragma at wxs.nl
Tue Mar 28 18:13:56 CEST 2006


Aditya Mahajan wrote:
> <--- On Mar 28, Taco Hoekwater wrote --->
>
>   
>> andrea valle wrote:
>>     
>>> Dear all,
>>> It's a bit tiring to start many lines always  with %.
>>> Is it possibile to have multiple line comments like in C
>>>
>>> \*
>>> comments here
>>> *\
>>>       
>> \iffalse
>>  comments here
>> \fi
>>     
>
> Be careful with this. From the UK tex FAQ
>
> The simple \newcommand{\gobble}[1]{} and \iffalse ... \fi aren't 
> really satisfactory (as a general solution) for comments, since the 
> matter being skipped is nevertheless scanned by TeX, not always as you 
> would expect. The scanning imposes restrictions on what you're allowed 
> to skip; this may not be a problem in today's job, but could return to 
> bite you tomorrow. For an example of surprises that may come to bite 
> you, consider the following example (derived from real user 
> experience):
>
> \iffalse % ignoring this bit
> consider what happens if we
> use \verb|\iftrue| -- a surprise
> \fi
>
> The \iftrue is spotted by TeX as it scans, ignoring the \verb command; 
> so the \iffalse isn't terminated by the following \fi. Also, \gobble 
> is pretty inefficient at consuming anything non-trivial, since all the 
> matter to be skipped is copied to the argument stack before being 
> ignored.
>   
This one is pretty safe: 

\startbuffer[comment]
    bla
    \startbuffer
    bla \iftrue \startbuffer bla bla
    bla \stopbuffer bla bla
    \stopbuffer
    bla
    bla
\stopbuffer

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the ntg-context mailing list