lua-users home
lua-l archive

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

I wrote:
Just one thought:

Block comments and literal strings are mostly meant for enclose large number of lines (less for literal strings that are useful, amongst other strings, to enclose Dos paths). At least, that's where there is the most likely potential problems.

Literal srings have already some conventions, like if they start by a new line, it is not enclosed in the string.

Why not make another convention, like starting (some) multiline block comments (literal strings) with --[[[ ([[[) anywhere in a line and ending them with ]]] (or --]]] as it is convenient) only at the start of line, a bit like the Perl/PHP HereDoc?

It lifts a lot of potential problems, as we rarely find code like:

val = t[a[f[i
]]] * 2;

aren't we?

Or, if really we want to take care of all cases, we can use the HereDoc syntax:

longText = [[TERMINATOR
foo bar
TERMINATOR]];    -- Always at start of line

Mmmm, not so bright, it is incompatible with simple use of this string, like:

path = [[C:\Good Languages\Lua\Bright Script.lua]]

unless we make additional rules like:

Single line literal strings/comments use old syntax, multiline ones always starts with new line or HereDoc terminator.

Or we use foo = [[[TERMINATOR
but I like it less (more exceptions).

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