www.digitalmars.com         C & C++   DMDScript  

D - For each syntax sugar

reply J Anderson <REMOVEanderson badmama.com.au> writes:
char [] a;
//Parhaps instead of
foreach (int i, char c; a) {}

//This could be used, when we want the standard foreach behavior, 
//where the first is the index and the second is the value.
foreach (i, c; a) {}

-Anderson
Dec 14 2003
parent davepermen <davepermen_member pathlink.com> writes:
hm.. you're hitting a serious point here, namely the point of implicit automagic
type deduction (or so:D)... wich is a very interesting way to implement
templates, too...

template max(a,b) { if(a > b) return a; return b; }

similar to C macros actually:D

not sure where that all goes, but its an interesting direction to think about..


In article <brjoa1$1re5$1 digitaldaemon.com>, J Anderson says...
char [] a;
//Parhaps instead of
foreach (int i, char c; a) {}

//This could be used, when we want the standard foreach behavior, 
//where the first is the index and the second is the value.
foreach (i, c; a) {}

-Anderson

Dec 15 2003