[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: # comments (proposal)
- From: "Szabolcs Szasz" <sz@...>
- Date: Tue, 11 Feb 2003 17:14:36 +0100
http://www.wraith.u-net.com/lua/ref5/man/manual.html#3.1:
"Comments (...)
For convenience, the first line of a chunk is skipped if it starts with #. This facility allows the use of Lua as a script
interpreter in Unix systems (see Section 7)."
Here the LUA syntax supports a common "UNIX use" specifically.
I'd like to bring attention to missing support for another
very common "UNIX use" case and a simple LUA feature that
could address it "for free".
A very practical and convenient use of embedded LUA is to
parse config files for a host program. Most config files
use a simple format on all UNIXes of var = "something"
syntax, which, luckily (and due to proper design), also
fits LUA syntax seamlessly.
However, those config files (being sh, perl, or other scripts
most of the time) traditionally also allow # comments. NB:
a number of (also embeddable) languages -- e.g. Ruby, PHP
-- adds support for # comments for the very reason of supporting
applications in the system-administration domain (besides
maintaining "cognitive compatibility" with those traditional
tools).
Unfortunately, the "--" LUA commenting syntax currently
prevents sysadmin tools from being developed utilizing the
convenient and powerful LUA 'dofile" technique for supporting
the common UNIX config file syntax.
Developing LUA-powered sysadmin tools could therefore get a
significant boost, as they could understand *tons* of existing
config files immediately, if the # comments would not be
explicitly limited to the first line of a file.
Relaxing that present limitation would:
1. allow trivial parsing of "unixersal" config files
from LUA-embedding tools
2. allow sysadmins to continue using/generating config
files for new LUA-aware programs the same way they
have been doing for other common tools
3. allow LUA-powered config-parsing programs to
coopearte with existing config-file-parsing tools,
using a vastly prevalent common syntax.
Best of all, all that would come for free, as there is nothing
special in LUA that would prevent using '#' from a line-comment
token; even to the contrary:
a) the '#' *IS* already used for comment syntax
b) LUA could get rid of that not very elegant rule of
treating the first-line # specially
c) backward compatibility would also be maintained
So, I would propose allowing # for general use as a line-comment.
5.0 coming out (and the great potential of LuaCheia for
popularizing the language) makes this time a perfect
opportunity for this very simple and very useful change.
Thanks for your attention,
Sab