Adtpp: lightweight efficient safe polymorphic algebraic data types for C

0Citations
Citations of this article
7Readers
Mendeley users who have this article in their library.
Get full text

Abstract

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 by adtpp 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, the adtpp 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.

Cite

CITATION STYLE

APA

Naish, L., Schachte, P., & MacNally, A. M. (2016). Adtpp: lightweight efficient safe polymorphic algebraic data types for C. Software - Practice and Experience, 46(12), 1685–1703. https://doi.org/10.1002/spe.2407

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free