Page 1 of 1

equivalent to "empty define" in LUA?

PostPosted: Sun Aug 12, 2012 13:09
by sapier
hello,
can anyone tell me if there is something in lua thats similar to an empty define in C?

Usecase is following in C/C++:

//#define DEBUG(x) some_debug_fct(x) //debug case
#define DEBUG(c) //empty in production


i've already tried following

--somename = trace_fct(text)
somename = function () end

but function doesn't seem to be a lightweight operation in lua :-(

PostPosted: Sun Aug 12, 2012 16:00
by sfan5
It works just fine for me:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> abc = function() end
> abc()
> print(abc)
function: 0x9f86b58

PostPosted: Sun Aug 12, 2012 16:09
by sapier
yes, I didn't mean it's not working just if you use an empty define in C/C++ its less than a NOP instruction.

using following code is far from a nop instruction but really needs cpu power!

abc = function () end
abc()