Structural abstraction: a mechanism for modular program construction
Huang, Shan Shan
MetadataShow full item record
Abstraction mechanisms in programming languages aim to allow orthogonal pieces of functionality to be developed separately; complex software can then be constructed through the composition of these pieces. The effectiveness of such mechanisms lies in their support for modularity and reusability: The behavior of a piece of code should be reasoned about modularly---independently of the specific compositions it may participate in; the computation of a piece of code should allow specialization, so that it is reusable for different compositions. This dissertation introduces structural abstraction: a mechanism that advances the state of the art by allowing the writing of highly reusable code---code whose structure can be specialized per composition, while maintaining a high level of modularity. Structural abstraction provides a disciplined way for code to inspect the structure of its clients in composition, and declare its own structure accordingly. The hallmark feature of structural abstraction is that, despite its emphasis on greater reusability, it still allows modular type checking: A piece of structurally abstract code can be type-checked independently of its uses in compositions---an invaluable feature for highly reusable components that will be statically composed by other programmers. This dissertation introduces two structural abstraction techniques: static type conditions, and morphing. Static type conditions allow code to be conditionally declared based on subtyping constraints. A client of a piece of code can configure a desirable set of features by composing the code with types that satisfy the appropriate subtyping conditions. Morphing allows code to be iteratively declared, by statically reflecting over the structural members of code that it would be composed with. A morphing piece of code can mimic the structure of its clients in composition, or change its shape according to its clients in a pattern-based manner. Using either static type conditions or morphing, the structure of a piece of code is not statically determined, but can be automatically specialized by clients. Static type conditions and morphing both guarantee the modular type-safety of code: regardless of specific client configurations, code is guaranteed to be well-typed.