lua-users home
lua-l archive

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


># 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.

This sounds reasonable but the current code looks at the first byte in
the chunk to decided whether to parse it as source code or to load it as
precompiled binary. But with a lua_load callback it can be made to work.

>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.

Except that in practice you'd want IDEs to be able to load full files and edit
and run them, even with the #! on the first line. Running them would be via
dostring. Of course, you could remove the #! line but if we start to do this,
there'll be a lot of code duplication around. Anyway, this is an issue that we
have been discussing, so perhaps 5.1 will bring a good solution.

>- it might be nice to have a 'savefile()' as well.

Lua 5.0 has lua_dump and also string.dump.
See test/luac.lua for a bare-bones luac.
--lhf