On 13.04.2012 1:48, Joseph Rushton Wakeling wrote:
On 12/04/12 21:54, bearophile wrote:
for( t=recordsRemaining-1; t>=limit; --t)
y2 *= top--/bottom--;
Generally packing mutation of variables inside expressions is quite
bad style. It makes code less easy to understand and translate, and
currently it's not defined, just as in C (it will be defined, but it
will keep being bad style).
OK. There's one other that should be a point of concern, where I have
return currentRecord++;
... in one function; I've added a selectedRecord variable to get round
this.
I believe it's something that reasonable people may disagree on. To me
it's perfectly easy to see what return x++; does. So is arr[i++] = ...,
so is arr1[i++] = arr2[j++]. But the downward loops look hairy all the
time ;)
Also in D there is (I hope it will not be deprecated)
foreach_reverse(), maybe to replace this for().
or use some std.range primitives ( I think iota does a [begin, end) range)
foreach( x ; iota(recordRemaining-1, limit+1, -1)){
y2 *= top--/bottom--;
}
[snip]
--
Dmitry Olshansky