lua-users home
lua-l archive

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


jimmyp:
> I justed wanted to vote in favour of this as well.This special rule
> that # is a comment but only on the first line is really well,... not
> cool

# on the first line is NOT a commenting scheme... it is an allowance for a
scripting language directive. Remember that even a *compiled* Lua module
will need a '#! Lua' at the front of it to run automatically, even though
the rest of the file is binary rather than human readable.

In fact, I think the allowance should be for a '#!' (not '#') and I don't
actually think that the '#' exception should be a part of the general Lua
syntax at all... but rather a part of the 'loadfile' / 'dofile' set.

Ie, the auto script running is a part of being a unix *file*, and so "#!"
only has meaning as the first line of a *file* (not a chunk) and 'dostring'
should not allow it. In essence, the main part of the Lua parser should
never see it.


While talking about compiled modules:
- it might be nice to have a 'savefile()' as well. Lua already has the
function internally compiled so it should be fairly trivial (and something
you can't do otherwise).

- 'loadfile()' should also return an additional file name (the "#!'
argument).

- 'savefile()' should optionally take an extra file name argument to be
saved as the '#!'.

- Toss in a "f = funcjoin(f1,f2,f3)" which merges functions and you have the
core of "luac" accessible to all.

*cheers*
Peter Hill.