odd syntax for foreach
    BCS 
    BCS at pathlink.com
       
    Sat Aug 19 12:58:23 PDT 2006
    
    
  
from: http://www.digitalmars.com/d/statement.html#foreach
<bnf>
ForeachStatement:
	foreach (ForeachTypeList; Expression) Statement
ForeachTypeList:
	ForeachType
	ForeachType , ForeachTypeList
</bnf>
Based on this the following is syntacticly correct.
void main()
{
char[] foo;
foreach(i,j,k;foo)
{}
}
In fact it gives the error
    foreach.d(5): cannot infer type for j
which tells you nothing of much use. The following syntax looks more 
reasonable to me.
<bnf>
ForeachTypeList:
	ForeachType
	ForeachType , ForeachType
</bnf>
    
    
More information about the Digitalmars-d-bugs
mailing list