equivalent to "empty define" in LUA?

sapier
Member
 
Posts: 763
Joined: Tue Aug 16, 2011 18:17

equivalent to "empty define" in LUA?

by sapier » Sun Aug 12, 2012 13:09

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 :-(
DON'T mention coding style!
(c) sapier all rights reserved
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sun Aug 12, 2012 16:00

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
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

sapier
Member
 
Posts: 763
Joined: Tue Aug 16, 2011 18:17

by sapier » Sun Aug 12, 2012 16:09

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()
DON'T mention coding style!
(c) sapier all rights reserved
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 12 guests