Extending type systems in a library: Type-safe XML processing in C++

Type systems built directly into the compiler or interpreter of a programming language cannot be easily extended to keep track of run-time invariants of new abstractions. Yet, programming with domain-specific abstractions could benefit from additional static checking. This paper presents library techniques for extending the type system of C++ to support domain-specific abstractions. The main contribution is a programmable ''subtype'' relation. As a demonstration of the techniques, we implement a type system for defining type qualifiers in C++, as well as a type system for the XML processing language, capable of, e.g., statically guaranteeing that a program only produces valid XML documents according to a given XML schema.

[1]  David E. Evans,et al.  Static detection of dynamic memory errors , 1996, PLDI '96.

[2]  Alexander Aiken,et al.  Implementing Regular Tree Expressions , 1991, FPCA.

[3]  P. Cochat,et al.  Et al , 2008, Archives de pediatrie : organe officiel de la Societe francaise de pediatrie.

[4]  David A. Wagner,et al.  This copyright notice must be included in the reproduced paper. USENIX acknowledges all trademarks herein. Detecting Format String Vulnerabilities with Type Qualifiers , 2001 .

[5]  Mark Nottingham,et al.  The Atom Syndication Format , 2005, RFC.

[6]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[7]  David Abrahams,et al.  C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ In-Depth Series) , 2004 .

[8]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[9]  Wolfram Schulte,et al.  The essence of data access in Cω: the power is in the dot! , 2005 .

[10]  Benjamin C. Pierce,et al.  Regular expression types for XML , 2000, TOPL.

[11]  Martin C. Rinard,et al.  ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), November 2002 Ownership Types for Safe Programming: Preventing Data Races and Deadlocks , 2022 .

[12]  Alexander Aiken,et al.  Flow-sensitive type qualifiers , 2002, PLDI '02.

[13]  David Walker,et al.  An effective theory of type refinements , 2003, ICFP '03.

[14]  Gavin M. Bierman,et al.  The Essence of Data Access in Comega , 2005, European Conference on Object-Oriented Programming.

[15]  Shane Markstrum,et al.  Semantic type qualifiers , 2005, PLDI '05.

[16]  David A. Wagner,et al.  Finding User/Kernel Pointer Bugs with Type Inference , 2004, USENIX Security Symposium.

[17]  Colin Runciman,et al.  Haskell and XML: generic combinators or type-based translation? , 1999, ICFP '99.

[18]  Fabio Vitali,et al.  Web information systems , 1998, CACM.

[19]  Gilad Bracha Pluggable Type Systems , 2004 .

[20]  Conor McBride,et al.  Functional pearl: i am not a number--i am a free variable , 2004, Haskell '04.

[21]  John Longley When is a functional program not a functional program? , 1999, ICFP '99.

[22]  C. M. Sperberg-McQueen,et al.  Extensible Markup Language (XML) , 1997, World Wide Web J..

[23]  Jeffrey S. Foster,et al.  Type qualifiers: lightweight specifications to improve software quality , 2002 .

[24]  Emmanuel Beffara,et al.  ICFP '03 Proceedings of the eighth ACM SIGPLAN international conference on Functional programming , 2003 .

[25]  Helmut Seidl Deciding Equivalence of Finite Tree Automata , 1990, SIAM J. Comput..

[26]  Todd L. Veldhuizen,et al.  Using C++ template metaprograms , 1996 .

[27]  Todd L. Veldhuizen,et al.  C++ Templates are Turing Complete , 2003 .

[28]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[29]  Lee R. Nackman,et al.  Scientific and Engineering C , 1995 .

[30]  Benjamin C. Pierce,et al.  The XTATIC Experience , 2004 .

[31]  Ralf Hinze,et al.  Generic programming in 3D , 2009, Sci. Comput. Program..

[32]  Michael J. Vilot,et al.  Standard template library , 1996 .

[33]  Alexander Aiken,et al.  A theory of type qualifiers , 1999, PLDI '99.

[34]  Benjamin C. Pierce,et al.  XDuce: A Typed XML Processing Language (Preliminary Report) , 2000, WebDB.

[35]  Alexander A. Stepanov,et al.  C++ Standard Template Library , 2000 .

[36]  William S. Brown Applied template metaprogramming in siunits: the library of unit-based computation , 2001 .

[37]  Alexander A. Stepanov,et al.  Generic Programming , 1988, ISSAC.

[38]  Andrew Kennedy,et al.  Dimension Types , 1994, ESOP.

[39]  John B. Shoven,et al.  I , Edinburgh Medical and Surgical Journal.

[40]  Jaakko Järvi,et al.  A comparative study of language support for generic programming , 2003, OOPSLA '03.