lua-users home
lua-l archive

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


Roberto Ierusalimschy a écrit :
When you really need the speed, you should consider the use of an
explicit counter inside the inner loop:

  i = i + 1
  aVeryVeryLongNameWrittenOnlyOnce[i] = new value

This is still faster than "a[#a+1]" (and avoids the original problem).

That's were the other frequent request come back: can we have a i += 1 notation? :-)
Not i++ (or ++i) as it has too much side effects...

You know:
whyDidIMadeThisVariableSoLong = whyDidIMadeThisVariableSoLong + 1
aVeryVeryLongNameWrittenOnlyOnce[whyDidIMadeThisVariableSoLong] = new value

Oh well... :-P

Frankly, sometime I really wish to have this += (-=) notation, even though I am not fan to make Lua look like C, unlike many users...
But I guess it has unwanted side-effects or problems.
Should we accept x, y += 1?
a, b += x, y?
Perhaps more trouble than it is worth.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --