Generators in D

KennyTM~ kennytm at gmail.com
Wed May 11 11:54:56 PDT 2011


On May 11, 11 08:06, Piotr Szturmaj wrote:
> I forgot to ask. Any comments or suggestions?

The argument match assertion is too strict. The following does not compile:

---------------
void main() {
     auto a = generator( (out int result, double e) {
         yield!result(1);
     }, 4);
     writeln(a);
}
---------------
x.d(40): Error: static assert  "Arguments do not match"
x.d(104):        instantiated from here: _generator!(void delegate(out 
int result, double e),int)
x.d(108):        instantiated from here: generator!(void delegate(out 
int result, double e),int)
---------------

Perhaps you could just remove the assert? The compiler will complain if 
the arguments cannot be accepted anyway.



More information about the Digitalmars-d mailing list