lua-users home
lua-l archive

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


On Thu, Oct 18, 2012 at 12:14 PM, Elias Barrionovo
<elias.tandel@gmail.com> wrote:
>> I have no idea about lua/luajit internals but i don't use `:` because i
>> imagine that interpreter has to additionally follow metatable on every call.
>
> I'd guess that in this case str:gmatch triggers only one metatable
> lookup, since gmatch will return an iterator that will be called
> throughout the loop.

right, the expression in the generic for is evaluated only once.

besides, a metatable indirection is far, far less expensive than most
processing done in any but the most trivial loop body (and is
optimized away by LuaJIT).

-- 
Javier