lua-users home
lua-l archive

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

> >About disabling code blocks
> Juts a reminder: there's the string trick:
> local C=[[
> --]]
> The block can be turned on again simply by adding -- to the first line.
> This does not generate bytecode for the block but adds a string...
> --lhf

Of course, if GC time isn't an issue, you can just write:
local C = [[
<syntaxly correct code to comment out>
--]] ; C = nil

and the string isn't in memory anymore (after the GC of course).

Erik Hougaard wrote:
> >Well from a color syntaxing viewpoint this is a bad solution :-(
> Only if it's hard to add coloring for multiline [[..]]] strings...
> --lhf

Usually, yes, strings and comments are often seen as monolithic, and are
rarely parsed for syntax highligthing.
Of course, there are some exceptions, like looking for doc. comments,
highlighting scripts in HTML comments, etc.
In a generic, ideal solution, we should highlight any code inside [[ ]]
comments, be it Lua code, HTML fragments, etc. Of course, one difficulty would be
to know which language to highlight. In HTML, it can be easy: <script
language="JavaScript">, or comments are tagged like <!--$$ $$--> (CGILua), or even
special tags (ASP, etc.) are ignored, thus seen as comments.
With just [[ ]], it is a bit harder... Unless we choose the convention to
discard the first line (or characters) of this string, holding the ID of the
language. A very personal choice indeed.


Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist

Sent through GMX FreeMail -