lua-users home
lua-l archive

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


On Mon, Jun 27, 2011 at 9:33 AM, Gaspard Bucher <gaspard@teti.ch> wrote:
> Another alternative is the old parse and compile. You use HASH("foobar") in
> your code and have a regexp + Lua preprocessor replace this by during the
> compilation process (with some proper makefiles, this is not as painful as
> it looks):

This seems preferable to having to mess with the core; such a
preprocess step is usually pretty fast.

Would be something like this in LuaMacro (which does C these days as well):

macro.define('HASH(x)',function(s)
  local s = tostring(s)
  local hash = my_hash_fun(s)
  return ('%d /* %s */"):format(hash,s)
end

steve d.