Skip to content

{ Tag Archives } generics

Comparing C#, C++, and Delphi (Win32) Generics

C#, C++, and Delphi all have a generic type and method language feature. Although all three languages are statically typed, they implement generics in very different ways. I’m going to give a brief overview of the differences, both in terms of language features and implementation. I presume that Delphi Prism generics work essentially the same [...]

Also tagged , , , ,

Generics, Commas, and Semicolons

In Delphi 2009, you declare a generic type with multiple type parameters by separating the type parameters with a semicolon. If the type parameters have a constraint, you separate the constraint using a colon. Like this:

TFoo<TypeParam1; TypeParam2: ISomething> = class

This means that TypeParam2 must support ISomething. In C#, you would use where instead [...]

Also tagged

Implementing Memoize in Delphi 2009

My last series on Delphi 2009’s generics was self-consciously investigating a corner case.  This post, however, is going to bring us back to Earth very quickly, so prepare for a steep descent!  I’m going to implement a useful, higher-order function, Memoize, using Delphi 2009’s generics and anonymous methods.
Memoization is a generic solution to the problem [...]

Also tagged , , , ,

Generics: Not Just for Lists

It appears that the next version of Delphi, code-named Tiburón, will include support for generic types in the Win32 compiler. Developers without .NET experience may not be familiar with use cases for generics. Of course, generics work really well for typed containers, and this is often the first example that people give as a use case. But they have many other uses as well. I’ll give a few examples; I hope this will help Delphi developers think about how they might want to use the feature in their own code.

Also tagged

Bad Behavior has blocked 1306 access attempts in the last 7 days.