Changing the foreach key...
ibisbasenji at gmail.com
Mon Oct 30 17:24:37 PST 2006
Karen Lanrap wrote:
> Chris Nicholson-Sauls wrote:
>>Instead it was a normal 'in' index, which was being manually
>>advanced to skip an iteration.
> That is impossible with 'in' parameters to a block.
> Therefore indexes are buggily implemented as 'inout'.
I don't think that's the case. Try foreaching over an associative array and setting the
value of the key. If the index were silently inout then the array would have differing
data afterward, which it does not.
It is not a parameter, but a variable within a scope like any other. Therefore, you can
do essentially anything you want with it. The fact that the loop is controlled by those
changes, only means that the foreach is rewritten effeciently, by not making invisible
temp variables to store loop state. I would consider that a feature.
-- Chris Nicholson-Sauls
More information about the Digitalmars-d-learn