views:

456

answers:

2

Hi,

I'm pretty frustrated. I'm using Delphi 2009 and was very happy about the inclusion of generics in this version of Delphi. Everything worked great at the beginning, but now that I use generics all over the place I run into problem after problem - most of the time some internal errors, where I don't even see where exactly they are caused. I tried restructuring the code multiple times to avoid the problems with generics but always run into new problems further down the line.

Now I decided to remove generics alltogether and use some dynamic casts to specialize my classes. Not very thrilled about it but i just don't see another option. I can't spend my day tracking down Delphi's internal compiler errors...

Is anybody using generics in a large project without running into such problems? Is it my fault perhaps? Or is it just not possible to use them in complex projects?

I hope D2010 fixes all this stuff.

+12  A: 

I'm using generics extensively in Delphi 2009, and I can say it's not easy as you are often required to work around an ICE. Even worse, generics even mess up with the linker, i.e. you can't really use them in packages (except for C++Builder packages).

All this trouble seems to be gone in Delphi 2010; I hardly ever saw an ICE due to generics. I need my code to work with both 2009 and 2010 though :(

Moritz Beutel
+7  A: 

Generics support in D2009 was really bad at first. Update 3 fixes a lot of things, but not everything, and leaves at least one serious bug in Generics.Collections.pas. In some ways, it actually got worse, since now instead of giving you a syntax error when the compiler chokes on some generic construct, you'll often get an internal compiler error and you don't know what's causing it.

It's been improved quite a bit for 2010. There are still a few generics-related problems in rather obscure cases, but they're generally safe to use as long as you're not using packages or putting generics inside of class helpers or strange things like that.

Bottom line: if you want to use them, upgrade to 2010.

Mason Wheeler