[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Shorthand for appending to a table (was Re: 5.2 feature list?)
- From: Philippe Lhoste <PhiLho@...>
- Date: Tue, 12 Sep 2006 17:14:21 +0200
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
Not i++ (or ++i) as it has too much side effects...
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.
-- (near) Paris -- France
-- -- -- -- -- -- -- -- -- -- -- -- -- --