lua-users home
lua-l archive

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


There seems to be no way of making Lua code say politely:
"This program requires Lua 5.3" when running under Lua 5.2.
Instead, one gets a nasty message like

./myprog.lua:28: unexpected symbol near '&'

as soon as it hits a bitwise operator.

But maybe it is not late for next time round.  We are already
ignoring one leading `#` line. 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 would allow elegant version control and more.

E.g.

#! /usr/bin/env lua
#@ _VERSION >= 6.0
#@ bit32

When Lua 5.3 runs this program, or Lua 6.0 runs it without
having preloaded a bit32 library, the rest of the file would not
even be looked at.