lua-users home
lua-l archive

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


Hello Lua Hackers,

2010/9/21 KHMan <keinhong@gmail.com>

So, source line 1 was compiled to 7 lines binary, line 3 was 8
lines, line 5 was 9 lines.

Look closely, why are you counting the RETURN?

I'm sorry, it's my mistake. Last RETURN becomes from whole chunk, not a single source line.  Exactly, source line 1 was compiled to 7 lines, line 3 and 5 were 8 lines.
 
So this is a 'win'? Colour me unimpressed.

The difference between line 1 and 3, a ternary operator and and/or, is little.  and/or needs one more TEST line (And, this TEST line is what I want to eliminate by a ternary operator...).  But the difference between line 1 and 5, a ternary operator and if-statement, is big.  With a ternary operator, a compiler calculated left operand of assignment only once.  But with if-statement, the left operand must be compiled twice.  When the left operand is complex, this difference became bigger.

Thank you,
Ryota Hirose