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.
Stop relying on risky TObject casts. Learn how to use Delphi Generics to move type-checking from runtime to compile-time, reducing crashes and boilerplate code.
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 Go generics cut boilerplate while keeping type safety and performance. A step‑by‑step guide with a concrete Max example, benchmarks, and practical trade‑off considerations.
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.