lua-users home
lua-l archive

Re: do you use the pre-processor?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2000年5月12日, Dave Gordon wrote:
> | 
> | How about starting it with "comment = [[" and ending with "]]". That's
> | what I usually do...
> 
> That's a good idea, but it doesn't work well in some cases. At least 
> I don't see a way to make it work in a situation I encounter often 
> while debugging my renderer. I use $if, $end to comment out sections 
> of large data arrays (vertex and polygon lists to be precise) to try 
> to locate regions of the data were a problem is occuring. For that
> purpose "comment = [[...]]" doesn't work because (I believe) there's 
> no valid syntax that allows it to be put it in the middle of table
> constructor consisting of a list of objects. So unless there's 
> another trick I'm missing I still think a block comment delimiter 
> would be helpful. That is in the absence of $if, $end of course.
There is a valid syntax for this case (a dirty trick, in fact)! If you
have a constructor like
 a = { 1.0, 2.0, 3.0, 4.0, 5.0 }
you can remove part of it with 
 a = { 1.0, [[2.0, 3.0, 4.0,]] and 5.0 }
A string is always true, so this `and' results in its second operand. It
does not work only when you want ro remove a sufix of the constructor.
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /