lua-users home
lua-l archive

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


On 1/8/07, askok@dnainternet.net <askok@dnainternet.net> wrote:

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 parameters

Or... perhaps I should start an online shop, crafting any
token filters anyone anywhere ever would like?   Would you
pay for it?  :)

-asko

ps. 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 no
>> function call
>
> There 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 tail
> call, that let you optimize a bit your stack usage.



hello,

for your mehtod, can you point me to some document or manual?

thanks.