lua-users home
lua-l archive

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


Hmm, you are using this like a macro facility :p

You could do this 2 ways.  Either way the function that executes at
compile-time should return something that can be represented as a
literal:

local debirand = function () return 4 end

local a = @debirand()

Or:

local C = function (c) return string.byte(c) end

if c == @C('?') then ... end -- becomes:

if c == 63 then ... end

The other part is the functions that execute at compile-time can
either take literals where they are called (so the compiler can
evaluate these by starting up a minimal Lua instance and running the
function), or it could also take arguments that reference other values
known at compile time:

local questionMark = '?'

@C(questionMark)

I don't really expect this to be upvoted.......  still fun to dream :-)