🎉 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: Operator Constraints & cd review

Published May 07, 2008
Advertisement
One of the kinda awkward problems in C# is the lack of a 'numeric' constraint for lack of a better definition. If you make a generic T, you can't do a+b since they might be objects... or something else where that doesn't make sense. And you can't provide a type constraint since int/float/etc don't have a common base type where the operators are defined. In general, the ability to say 'Type T for this generic must have T+T -> T' doesn't exist.

Since Tangent is going to be fairly operator and interface heavy, I'm highly motivated to provide some mechanism where that type/operator inter-relation requirement exists. I am unfortunately an uncultured swine, so am likely re-producing an existing solution (badly).

The current solution is (I think) similar to some of the Type Class stuff in Haskell (but not knowing Haskell, or finding example/documentation which is not too simplistic or too advanced -- I can't say for sure). And it's quite similar to declaring an abstract method for a class. When used as a variable or type constraint on a generic, the existence of that signature for the specified operator is checked at compile time.

public class Addable{   public this @plus(this,this);    // + is an alias for the global method                                     //   'plus'                                    //                                    // The @ symbol is the tentative syntax                                    //  for an absolute identifier path/name.}public class foo{   public static T add(T lhs, T rhs) where T: Addable{       return(lhs+rhs);   // this is fine because the constraint says it will be   }} foo.add(5,6);       // fine, 2 ints return an int.foo.add("moo",4);   // error, string and int don't match the signature.foo.add(x,y);       // error if x+y is undefined


And since operators are overloadable and types are ducktyping, foo.add will behave nicely for anything that overloads plus properly, regardless if that anything inherits directly from Addable.

Seems spiffy. Hopefully it doesn't cause loops on checking or fragile stuff at runtime if people are bad about operator overloading or annoying stuff if I'm too stringent on disambiguation. We'll see once I get more done/working.


In other news, a CD review!

After a quick poll, everyone in my car seems to agree that they like Evanescence. They can't really agree on anything else they like, and they're all kinda fed up with listening to them. So last week I pooled up some cash, went to Amazon and did a 'similar to' search. Checked some youtube clips and generally hunted about for bands I've never heard of under my rock.

The (decidedly European) results:
God has a Plan for Us All - Angtoria
The Heart of Everything - Within Temptation
Century Child - NightWish


And all in all, I'm pretty impressed with the suggestions. The quality is good, and the sound is quite similar. It's kind of amusing to listen as each of the bands seem to have a separate strength.

Angtoria - The darkest of the three CDs, also has a cover of Kylie Minogue's Confide in Me. The lead singer is probably the strongest of the three, though the backing band is a little sloppy and the compositions are just lacking in some of the variation and catchiness. This is their debut CD though, so that is likely to improve a bit. A good CD, not great with some promise for the future. 7 of 10.

Within Temptation - The most mainstream of the three CDs. This is a solid cd. Every track is good to great; none of those 'bleh - skip it' dead tracks on most CDs. The sound is fairly uniform throughout, though the songs do distinguish themselves. The band isn't hugely outstanding, as is the singer, just consistently above average. The lyrics aren't as vivid or creative as Evanescence, and the performances aren't as emotional. They are though a bit more technically sound and consistently good. Still, great CD; highly recommended. 9 of 10.

NightWish - A popular band across the pond, Century Child is an older CD before they changed singers. These guys are the most 'metal' of the three, and have the most operatic sound to the vocals. Unfortunately the operatic sound isn't very good. The band is very good. The compositions have a fairly high technical difficulty for semi-mainstream music and the performance really nails them. No sloppy playing, no noise for the sake of noise. The songs vary a bit, and some miss. The ones that hit hit well though. Included is a symphonic/gothmetal cover of 'Phantom of the Opera'. All in all pretty good after some re-listening. 7 of 10.
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