lua-users home
lua-l archive

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


Hi,

What do you guys prefer between iterators vs lambdas? For example, you
have a function find("/directory", "pattern") where the function will
find every entries that matches the pattern.

Would you rather use like that:

for entry in find("/directory/", "*bar")
    -- Play with entry
end

Or with a lambda called with the entry as argument

find("/directory/", "*bar",
    function (entry)
        -- Play with entry
    end
)

The second one maybe more performant (I guess, not tested) on huge
objects. Also the second one may use different function as parameter
without rewriting the for loop in the first one.

So I would like what you usually prefer before I'm going further in my
project because it will require a lot of these kind of calls :-).

Warm regards,

-- 
Demelier David