On 03/02/2012 12:12 AM, bearophile wrote:
Ali:
Note that Timon's inner foreach is a compile-time foreach, which is the
equivalent of the following three lines:
I'd like it to be written:
static foreach (...) {...
In the meantime an annotation helps clarify the code for the person that will
dear,
Noob question for know if D provide a shorter way i explain
we have a struct S:
struct S{
string member1;
string member2;
string member3;
}
we parse a file:
File f = File(a path, r);
S s;
sise_t tokenLength = member1.length;
foreach( char[] line; f.byLine() )
On 03/01/2012 10:50 PM, bioinfornatics wrote:
dear,
Noob question for know if D provide a shorter way i explain
we have a struct S:
struct S{
string member1;
string member2;
string member3;
}
we parse a file:
File f = File(a path, r);
S s;
sise_t tokenLength =
Le jeudi 01 mars 2012 à 23:10 +0100, Timon Gehr a écrit :
S s;
size_t tokenLength = member1.length;
void main(){
foreach(char[] line; stdin.byLine())
foreach(m;__traits(allMembers,S)){
if(line[0..tokenLength] == m) mixin(s.~m) =
line[tokenLength
.. $].idup;
}
}
On 03/01/2012 02:25 PM, bioinfornatics wrote:
Le jeudi 01 mars 2012 à 23:10 +0100, Timon Gehr a écrit :
S s;
size_t tokenLength = member1.length;
void main(){
foreach(char[] line; stdin.byLine())
foreach(m;__traits(allMembers,S)){
if(line[0..tokenLength] == m) mixin(s.~m) =
Ali:
Note that Timon's inner foreach is a compile-time foreach, which is the
equivalent of the following three lines:
I'd like it to be written:
static foreach (...) {...
In the meantime an annotation helps clarify the code for the person that will
read the code:
/*static*/ foreach (...)