x='foo'_G[x]()-- calls foo from the global namespace
example described in that stackoverflow link, but I would like to use macros instead of functions, for the sake of memory (and speed?). But I'm not sure if that's possible, or if possible how to call those macros dynamically.
To be extra clear, right now I'm doing something like this and it's working fine:
function snippetA()--some codeend--To call the above function
letter ="A"
whatToCall ="snippet" .. letter
call=_G[whatToCall]call()--> "some code" get executed
But I'd like to use macros instead:
snippetA @|--some code|-- How can I call the above macro in the same manner as the function?
letter ="A"
whatToCall ="snippet" .. letter
-- now what? The _G[whatToCall] obviously doesn't work.
Comments
https://stackoverflow.com/questions/1791234/lua-call-function-from-a-string-with-function-name
[-] Liasoft
I'm already doing the
To be extra clear, right now I'm doing something like this and it's working fine:
Macros only exists at compile time, no longer at run time.
Likes: antix, saeys