lua-users home
lua-l archive

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


On 15/06/2011 19.29, Roberto Ierusalimschy wrote:

[snip]

Some real contenders:

1) keep all as it is
2) change the indication of filenames in debug info and in LUA_INIT
3) ::label::
4) |name|
5)&name:
6) !name:


I had a weird idea for 3 (which I consider the best of those options, as I said elsewhere), but since we are brainstorming... :-P

What about an approach like long comments and long strings? The label is marked by a sequence of two or more colons of the same length on both sides. For example:


...
do return 0 end
::error1::
print("error 1!")
do return 1 end
::error2::
print("error 2!")
do return 2 end
:::::::::::::resume:::::::::::::
print("resuming")
...


This would allow people to emphasize a label in different ways according to some criteria and code highlighters could help making them stand out (I imagine, e.g., SciTE marking labels with a solid yellow background, so that they could also be used as visual separators for different code segments).

I'm not sure if it is a good idea. Comments welcome! :-)

Note that, if this is a good idea indeed, the other candidate syntax wouldn't be so pretty. The asymmetric ones would be REALLY ugly:

&&&&&&label::::

and would force the programmer to actually count the sigils (no copy+paste). As for the other symmetric alternative, compare:


||||||label||||||

(label visually almost disappear in that sea of '|' chars, unless you put spaces around it, which I would disallow to avoid unreadable code if abused).


[snip]


-- Roberto




-- Lorenzo