Jump to content
  • Advertisement
  • entries
  • comments
  • views

Tangent: foreach beginnings

Sign in to follow this  


As usual, I'm not as bright as I think. the yield stuff ran into a roadblock because the vague design proved not viable for anything beyond the simplest case. And it's not the sort of thing that you can just look up... Full coroutines are not the sort of thing I want (or rather want to dedicate the time to implement well), and everything else is how to hack the behavior using goto or exceptions or C macros.

So I went to work on foreach. The thread about for loops in the last posting was actually pretty insightful. In general people seem not to care for the C style loop so much. And while it might be interesting to leave such a construct to the library, I think it's something that's used enough that it should be dealt with.

"Make the easy things easy."

So, foreach will exist at least as a statement; mostly the same as C#:

foreach ( in ){...}

It's slightly unlike C# in that it is built after generics. The IEnumerable expression must be of a compatible type to the variable; I'm not auto-casting from Object.

The parser and code generation worked pretty well with minor bughunting. Unfortunately, I ran into IEnumerable importing problems (since fixed) and bug #14 (the runtime doesn't generate local variables within sub-blocks). So it looks like I'll need to get to that bug a little before I anticipated.

That'll be a bit of work, but should then allow this to work as expected. Then on to yield completion and a few example programs. By then I'll probably need to do some backfill on phrases and generics where I missed some stuff.
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!