🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tangent: Method Tests Part 3

Published March 02, 2009
Advertisement
A few of the fruits from the last big refactoring to show today. Phrases now can act as generators, and delegates can nicely deal with generators:

public static    nums()               => yields<int>{ yield(0); yield(1); yield(2); }public static    some nums            => yields<int>{ yield(0); yield(1); yield(2); }public static    good many nums       => yields<int>{ yield(0); yield(1); yield(2); }//// bug #39//public static    (int min) to (int max)        => yields{ int x = min; do{ yield(x); x = x+1;}while(xpublic static delegate    yieldDel()       	 => yields<int>;public static main()=>void{foreach(int x in nums()){        print x;    }    foreach(int x in some nums){        print x;    }    foreach(int x in good many nums){        print x;    }    yieldDel = nums;    foreach(int x in yieldDel()){        print x;    }}


012012012012


Infix methods as generators don't quite work yet, but at least I identified that. They'll work soon enough.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement