|
Disclaimer: mentioning token filters is rapidly becoming a de-facto giving-you-an-answer-without-really-solving-the-issue in Lua. This will no doubt start irritating some users (me included).
Here we go again... :)One could define an "id= inline [(...)] ...expressions... end" block to behave as a user provided macro; it would not generate any bytecode itself, but define that any time 'id [(...)]' is used in the source, it would be replaced by the ...expressions... . While this would be exactly what you're asking for, and there's no really other drawbacks than the ones connected to token filtering itself (and maybe bigger bytecode, but you're implying that by inline anyways), I would _not_ recommend doing this.
[(...)] for optional parametersOr... perhaps I should start an online shop, crafting any token filters anyone anywhere ever would like? Would you pay for it? :)
-askops. In practise: use the C preprocessor to define the inlines. Will that do it?
On Sun, 7 Jan 2007 11:40:15 -0500 "Jérôme VUARAND" <jerome.vuarand@gmail.com> wrote:
2007/1/7, howard chen <howachen@gmail.com>:Are there similar to C/C++ inline function systax in Lua?I have a small function but will be called quite frequent, if inline-ed, it might give some performance gain as there will be nofunction callThere is no such thing as inlining in Lua, since the closure mechanism used by Lua impose to resolve most things at runtime. The only optimization in stock Lua specific to functions calls is the tailcall, that let you optimize a bit your stack usage.