🎉 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 Tidbits.

Published September 02, 2008
Advertisement
Not much done over the long labor day weekend. Social obligations brought me away from the internet. Not so bad with a good book (American Gods) if it's infrequent.

Tangent work tonight was some updates to the .NET importer and certain bits of the type system to support importing generic types such that the objects still interoperated with .NET where only .NET types were involved, but supported Tangent types for the generic params. Plus getting Tangent's partial application of type params working beside .NET's required full application. Pretty much entirely aimed at getting lists and dictionaries.

Most things seem to be there now. The types are imported nicely, the generic params setup for the equivalent Tangent Type. I'm not exactly a whiz at .NET reflection, so I'm feeling my way into discovering the vagaries of generic parameters and the such. Plus some of the bits and oddities surrounding enumerators and explicit interface implementations. Those things are keeping the useful bits of Lists from being imported. Once that's done, I'll need to add generic type binding to Tangent syntax; and then foreach.

I've got 3 choices I figure for Tangent foreach.

1- Make it just like C# foreach.
2- Include an implicit 'where typeof(x) == foo':

List Inventory;//...foreach(Bottle entry in Inventory){    // implicitly no-op on Inventory entries which are not Bottles    quaff entry;}


3- Implement primitive matching (essentially sugar for anonymous method groups) and make foreach a specialized use for it:

//// syntax designed on the fly!//List Inventory;//...foreach(entry in Inventory){  match (entry)=>void{    (Bottle)=>{ quaff entry; }    (Garbage)=>{ drop entry; }    (NuclearWeapon)=>{ activate entry; }    (Any)=>{ }  }  }


Not quite sure yet. #3 can mostly be implemented on-top of 1 or 2 if need be. I'm wary of treading on functional niceties at this point. Not familiar enough to know many of the nuances, quirks and expectations of them. I'm not too worried that the naive use cases aren't sufficient enough for getting stuff done, but I'm not too confidant that I'd implement things sufficiently for those who are aware of the quirks.
0 likes 1 comments

Comments

Daerax
IMO anything other than 1 and 3 will be poor. Have it like C# and have seperate match functionality not tied to foreach. That also makes 2 redundant.
September 03, 2008 08:19 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement