I Language: Variable Self-Modification
Posted 2011-06-18 15:25:30 by Caglow
Increment, decrement, multiply by self, etc.Operators for these functions, long overdue, have now been implemented. Currently, the following operators have been implemented:(var) += (num) Increment(var) -= (num) Decrement
(var) *= (num) Multiply
(var) /= (num) Divide
(var) %= (num) Modulo
(var) ^= (num) Power
(var) :: (num) AppendIn addition to being syntactic sugar, these may also offer performance gains, but only in some instances.The only of these operators with appreciable difference are += and -=, mainly because addition and subtraction are extremely fast compared to the other operations. Under normal circumstances where a variable is being incremented or decremented, these operators will be about 80% slower than using a = a + 1 or the equivalent. However, if the variable to be incremented or decremented is indexed in a table (ie. a[1] = a[1] + 1), then the difference is made up for. If the variable is inside two tables (ie. a[1][1] = a[1][1] + 1), then there is a 25% gain in speed.Multiplication and division show similar but scaled down results (about 10% as extreme). Modulo, power and append operations are scaled < 1% from the above results.
Go to this project's news index
Go to overall project news index
Go to project page
