Ada's Dependent Types: An Unexpected Coincidence
This article explores the lesser-known dependent types feature in the Ada programming language. The author argues that Ada's design goal of avoiding unnecessary dynamic memory allocation led to its unique implementation of dependent types: using a second non-call stack to return data of unknown compile-time size, cleverly circumventing the need for dynamic allocation. This unexpectedly coincides with the formal definition of dependent types, showcasing an unforeseen serendipity in Ada's design. The article further explains concepts in Ada's type system such as derived types, subtypes, discriminated records, and type predicates, demonstrating how these features enable the implementation of dependent types. Finally, the author discusses the interesting interplay between Ada's design philosophy and academic research on type theory, suggesting that many of Ada's type system features didn't originate directly from type theory research, but rather evolved naturally to meet specific needs.
Read more