Adtpp: lightweight efficient safe polymorphic algebraic data types for C. (13th May 2016)
- Record Type:
- Journal Article
- Title:
- Adtpp: lightweight efficient safe polymorphic algebraic data types for C. (13th May 2016)
- Main Title:
- Adtpp: lightweight efficient safe polymorphic algebraic data types for C
- Authors:
- Naish, Lee
Schachte, Peter
MacNally, Aleck M. - Abstract:
- Summary: Adtpp is an open‐source tool that adds support for algebraic data types (ADTs) to the C programming language. ADTs allow more precise description of program types and more robust handling of data structures than are directly supported by C. ADT definitions and other declarations are put in a file that is preprocessed byadtpp to produce a C header ('.h') file that can be included in C source files. The generated header file contains C type definitions, macros, and inline functions that support type‐safe construction, deconstruction, and pattern matching of ADT values while avoiding unsafe operations such as casts, and avoiding the risk of errors such as dereferencing NULL pointers and accessing inappropriate fields of unions. Values are represented efficiently, using techniques from the implementation of declarative languages. For many simple data types, the memory representation is identical to a direct implementation in C, with no loss of efficiency. For more complex types, theadtpp representation is more efficient than common C representations while preserving type safety and convenience. As an example, we present a new variation of 234‐trees that is very compact.Adtpp also supports parametric polymorphism such as defining a type 'list of t ', where t can be any ADT, and generic functions such as length. However, polymorphic code is somewhat more verbose than for typical declarative languages, due to our reliance on the limited type checking available in C.Summary: Adtpp is an open‐source tool that adds support for algebraic data types (ADTs) to the C programming language. ADTs allow more precise description of program types and more robust handling of data structures than are directly supported by C. ADT definitions and other declarations are put in a file that is preprocessed byadtpp to produce a C header ('.h') file that can be included in C source files. The generated header file contains C type definitions, macros, and inline functions that support type‐safe construction, deconstruction, and pattern matching of ADT values while avoiding unsafe operations such as casts, and avoiding the risk of errors such as dereferencing NULL pointers and accessing inappropriate fields of unions. Values are represented efficiently, using techniques from the implementation of declarative languages. For many simple data types, the memory representation is identical to a direct implementation in C, with no loss of efficiency. For more complex types, theadtpp representation is more efficient than common C representations while preserving type safety and convenience. As an example, we present a new variation of 234‐trees that is very compact.Adtpp also supports parametric polymorphism such as defining a type 'list of t ', where t can be any ADT, and generic functions such as length. However, polymorphic code is somewhat more verbose than for typical declarative languages, due to our reliance on the limited type checking available in C. Copyright © 2016 John Wiley & Sons, Ltd. … (more)
- Is Part Of:
- Software, practice & experience. Volume 46:Number 12(2016)
- Journal:
- Software, practice & experience
- Issue:
- Volume 46:Number 12(2016)
- Issue Display:
- Volume 46, Issue 12 (2016)
- Year:
- 2016
- Volume:
- 46
- Issue:
- 12
- Issue Sort Value:
- 2016-0046-0012-0000
- Page Start:
- 1685
- Page End:
- 1703
- Publication Date:
- 2016-05-13
- Subjects:
- algebraic data types -- C language extension -- generics -- polymorphism -- safety -- static checking -- open‐source
Computer software -- Periodicals
Computer programming -- Periodicals
Computer programs -- Periodicals
005.3 - Journal URLs:
- http://onlinelibrary.wiley.com/ ↗
- DOI:
- 10.1002/spe.2407 ↗
- Languages:
- English
- ISSNs:
- 0038-0644
- Deposit Type:
- Legaldeposit
- View Content:
- Available online (eLD content is only available in our Reading Rooms) ↗
- Physical Locations:
- British Library DSC - 8321.453000
British Library DSC - BLDSS-3PM
British Library STI - ELD Digital store - Ingest File:
- 2560.xml