.NET Brain Droppings

I'm a Microsoft Certified Architect (MCA)... Feel free to ask me about the program...

One reason why Gyro rocks

If anyone saw Don Box's post today on delegates being the monikers of .NET (excellent article by the way), they may have seen a preview into the future.  Check out the code sample from Don's article:

public sealed class Tester2 {
    static IEnumerable<object> Generate(Predicate p) {
      List<object> list = new List<object>();
      foreach (object o in MyGoop) {
          if (p(o))
            list.Add(o);
      }
      return list;
    }
}
 
Anyone see the cool template code? If you've never used templates in C++ or Gyro, they are designated by the <> after a type reference. Very cool! I've been messing with Gyro for a while now, primarilly because I know it's the working draft for templates in Whidby. I can't wait for templates in C#. I am so sick of casting and writing "collection classes". Whoo Hoo!!!!!
If anyone is interested in learning more about generics in the CLR, take a look at the generics add on for Rotor @ http://gyro.sscli.net/.

Comments

Darren Neimke said:

yes, generics look pretty cool, but... would the code that Don showed us be functionally any different if I wrote it like so...


public sealed class Tester2 {
static IEnumerable Generate(Predicate p) {
List list = new List();
foreach (object o in MyGoop) {
if (p(o))
list.Add(o);
}
return list;
}
}
# July 21, 2003 11:33 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)