lua-users home
lua-l archive

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


On 03/26/2014 06:53 AM, Luiz Henrique de Figueiredo wrote:
We could equally well ignore all leading `#` lines and tag some of
them as expressions to be asserted _before_ proceeding to lexical
analysis of the file.
This is easily done with a custom reader function for load.

Wouldn't that mean you would have to replace the loader in the code being loaded. The only solution I see is to have a wrapper code around the actual code.

But than you could also just write:

if _VERSION ~= "Lua 5.3" then
    error "This code needs Lua 5.3"
else
    load [[
Do()
Some()
Stuff()
]]

But I think that has some disadvantages too. Like losing the file name and lines in the debug info. It seems to me that something like a static assert would be the right thing here.
--
Thomas