lua-users home
lua-l archive

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

Roberto Ierusalimschy wrote:
And (at least for me) the real interesting question is *why*
you cannot do with functions what you can do with macros.
Macroses operate in compile time, while functions operate in runtime.
Function are forced to obey syntax and semantics, while macros can change both. Functions can manipulate only values, while macroses can manipulate "segments of computation" (expressions and statements) (e.g. one cannot write elegant looking ifthenelse function, there will be a bunch of lambdas)

One can surpass "limitations" of functions with the help of first-class functions and runtime code generation. But if he chooses such path, then one day he will find a buggy home brewed macro facility inside his code.