🎉 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: foreach.

Published January 21, 2009
Advertisement
I finished a working solution to the nested block variable access bug. Probably not the best solution, but it works. As you might expect by the name, variables declared more than two blocks deep now don't cause runtime errors.


That also means C# style foreach now works:

public static void main(){	local List<int> foo = new List<int>;	foo.Add(1);	foo.Add(2);	foo.Add(3);	foreach( int x in foo ){		print x;                   // 123	}}



A functional style foreach will have to wait until method generics work a little better. Next on the list is making yield work. Maybe tonight, probably not.
0 likes 2 comments

Comments

Jotaf
Looks an awful lot like C++/C# [smile] That's a good thing though, it will make it easier for people with those backgrounds to easily get into Tangent.

Of course, what's happening under the hood is not really apparent from this point of view, but that's only a good thing IMO.
January 23, 2009 12:21 PM
Telastyn
Quote: Original post by Jotaf
Looks an awful lot like C++/C# [smile] That's a good thing though, it will make it easier for people with those backgrounds to easily get into Tangent.


That's the idea. Plus the original goal was to make C# with first class functions; things kinda expanded from there. And since .NET objects can be used from within the language it needs to provide the same sort of mechanisms, so they might as well follow the same sort of syntax.

Quote:
Of course, what's happening under the hood is not really apparent from this point of view, but that's only a good thing IMO.


Indeed, though to be honest foreach doesn't really behave under the hood any differently (besides the lack of automated casting) than it does in C#. No need to change something that works well.

January 23, 2009 01:07 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement