Type-Safe Delphi Collections with Generics
Replace unsafe casts in Delphi collections with compile-time generics. Learn how generic lists and custom stacks catch type errors at build time, plus trade-offs in binary size and compile time.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Replace unsafe casts in Delphi collections with compile-time generics. Learn how generic lists and custom stacks catch type errors at build time, plus trade-offs in binary size and compile time.
Carbon checks generics at definition time against interfaces, not per instantiation like C++ templates. This yields earlier errors, separate compilation, and clearer diagnostics, but sacrifices template metaprogramming and specialization. C++ interop requires explicit bridging.
Learn how Kotlin's inline functions and reified type parameters overcome JVM type erasure to create cleaner, type-safe APIs without the boilerplate of passing Class objects.
Learn how Crystal’s gradual typing lets you write flexible containers that stay type‑safe by applying generic constraints and the `type` keyword.
Discover how Go’s generics let you replace boilerplate with a single, fast, type‑safe function. Follow a concrete Max example, see the performance impact, and learn when to keep generics in check.
Before Delphi 2009, the built‑in TList stored TObject references and forced developers to cast every addition and retrieval, opening the door to runtime type errors. Delphi’s generics, especially TList<T>, let you declare the element type once and get compile‑time safety without extra casting.
Ceylon removes Java's wildcard boilerplate with declaration-site variance and type inference, but JVM erasure means bridge methods and hidden casts remain. Here is how to verify the tradeoff before adopting it.
Delphi’s generic types give compile‑time safety and clean code, but they can inflate your binary. Learn how to use generics, constrain types, and measure the impact in a real example.
Zig's comptime turns types into ordinary compile-time arguments, giving you monomorphized generic containers with no void* and no runtime cost. A worked List(T) example, plus the trade-offs.