lua-users home
lua-l archive

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


On 13/06/2011 21.52, Roberto Ierusalimschy wrote:
Due to the introduction of labels, '@' can now appear as the first
character in a valid Lua chunk. This means that the following passage
from lua_Debug is incorrect: "If source starts with a '@', it means
that the function was defined in a file where the file name follows
the '@'. If source starts with a '=', the rest of it should describe
the source in a user-dependent manner. Otherwise, the function was
defined in a string where source is that string."

We thought about that. At the time, it seemed that users could simply
avoid starting a chunk with a label (a simple space, newline, or a
comment would be enough). But now that thought seems feeble. The two
obvious solutions would be to change the character that marks filenames
or the character that starts labels. The second option has the slight
advantage of not creating a small incompatibility. Suggestions?

-- Roberto



Mmm, IMHO better to change the syntax for label.
BTW they look a bit ugly as they are now (but maybe this is intended :-)

If the start character must be something unused in Lua, there are few alternatives among ASCII: #, $, |, &, ?, !, `. Probably the best bets are # and $, since the other may better serve as operators in Lua 9.5 :-P :-)

Moreover I find that colon at the end of a label distracting: it seems to hint at a sort of connection with the following statement, which is wrong (as I get from the docs - BTW a little goto usage example in the manual won't hurt).

I would prefer something more "bulky", since labels mark point in code and are statements syntactically, e.g.:

$MyLabel$

$[MyLabel]

$[MyLabel]$

#MyLabel#

#[MyLabel]

#[MyLabel]#


I like the versions with brackets best. They are bulky, they stand out in code, but the label name is still readable (hoping they won't confuse the parser).

Cheers
--Lorenzo