Jump to content
  • Advertisement
  • entries
  • comments
  • views

Tangent: Enumerable interface, part 3.

Sign in to follow this  


The battle versus IEnumerable has been won!

The type (and IEnumerator) imports nicely now. It's nicely specialized within List, and is all nice and typesafe. The following example code compiles and runs nicely:

public static void main(){
local List<int> x = new List<int>;


local IEnumerator<int> itr = x.GetEnumerator();

print itr.Current; // 123


Oddly enough, none of the problems with it were the sort I expected; and didn't have much to do with the specialization of the generic and non-generic bits. The two major bugs were that I neglected to care about explicitly defined interfaces, and I was being dumb about how I new'd dotNet types.

I would generate the object for the .NET type and then store the value in it based off of the return of the invoke. This caused problems for abstract types/interfaces, since they can't just be new'd as is. As a bonus, that should cut down on the number of allocations during common use.

Next in the queue is almost certainly implementing the for loop now that this stuff is done. Not quite sure how that's going to go, so visit the thread about it, and put in your two cents. Damned laze-abouts...
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!