lua-users home
lua-l archive

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


On Wed, Aug 31, 2011 at 13:41, Mike Pall <mikelu-1108@mike.de> wrote:
> Alexander Gladysh wrote:
>> On Sat, Aug 27, 2011 at 11:29, Alexander Gladysh <agladysh@gmail.com> wrote:
>> > 1. I'm content with the fact that the pairs() would always be slow.
>> >
>> > 2. However, if pairs() abort the trace of any function...
>> >
>> > 3. ...Then that *any* function may never be compiled to the native code.
>> >
>> > 4. And that function may do something complex and optimizable besides
>> > calling pairs()...
>> >
>> > 5. ...Which would never be optimized due to #3.
>> >
>> > So, should I, for example, move the body of a loop with pairs() to the
>> > separate function so it would be compiled? Or what?
>>
>> Mike, I'm very sorry to waste your time on dumb questions, but could
>> you please shed some light here? ("No" or "Yes" would suffice if
>> you're too busy to give a detailed answer.)

> 1. Happily ignoring my advice.

Your advice is (1) to avoid table cloning as much as possible as it is
a "sign of design weakness"  and (2) avoid using pairs() as it "will
always be slow".

I did not ignore that advice, but it is not always possible to follow.
Even if I will figure out how to do this in that particular program
that lead me to start this thread, I will have to rewrite it from
scratch.

> 2. Yes.
> 3. Not if the function itself doesn't contain the call to next().
> 4. See 1.
> 5. No.

I see.

> 6. Why don't you try? -jv tells you what happens.

I will, thank you.

Thank you very much for your valuable time!

Alexander.