DMD 0.170 release

Hasan Aljudy hasan.aljudy at gmail.com
Tue Oct 17 06:09:16 PDT 2006



Walter Bright wrote:
> Walter Bright wrote:
>> Added foreach_reverse, which addresses a serious shortcoming.
>>
>> http://www.digitalmars.com/d/changelog.html
> 
> 
> Lots of background for the foreach improvements in:
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/17320.html

I just go an idea.
How about adding new statements:
skip;
reverse;

They can be used inside the foreach body to skip over the next iteration 
or reverse the order of iteration (dynamically at runtime).

Also, since foreach already takes two arguments (int i, T t) that is, 
index and element, you can add a third argument, of bool type, with the 
meaning "start in reverse mode"
foreach( true, i, d; "Hello" )
{
     writefln( d );
}

should print:
o
l
l
e
H




More information about the Digitalmars-d-announce mailing list