The preprocessor of the C language provides a standard way to generate code at compile time. However, writing and understanding these macros is difficult. Lack of typing, statelessness and uncommon syntax are the main reasons of this difficulty. Haskell is a high-level purely functional language with expressive type system, algebraic data types and many useful language extensions. These suggest that Haskell code can be written and maintained easier than preprocessor macros. Functional languages have certain similarities to macro languages. By using these similarities this paper describes a transformation that translates lambda expressions into preprocessor macros. Existing compilers for functional languages generate lambda expressions from the source code as an intermediate representation. As a result it is possible to write Haskell code that will be translated into preprocessor macros that manipulate source code. This may result in faster development and maintenance of complex macro metaprograms.
Publié le : 2017-02-07
Classification:
other areas of Computing and Informatics,
C preprocessor, functional programming, Haskell, program transformation, transcompiler,
68N15
@article{cai3380,
author = {Boldizs\'ar N\'emeth; E\"otv\"os Lor\'and University, Budapest and M\'at\'e Kar\'acsony; E\"otv\"os Lor\'and University, Budapest and Zolt\'an Kelemen; E\"otv\"os Lor\'and University, Budapest and M\'at\'e Tejfel; E\"otv\"os Lor\'and University, Budapest},
title = {Defining C Preprocessor Macro Libraries with Functional Programs},
journal = {Computing and Informatics},
volume = {35},
number = {4},
year = {2017},
language = {en},
url = {http://dml.mathdoc.fr/item/cai3380}
}
Boldizsár Németh; Eötvös Loránd University, Budapest; Máté Karácsony; Eötvös Loránd University, Budapest; Zoltán Kelemen; Eötvös Loránd University, Budapest; Máté Tejfel; Eötvös Loránd University, Budapest. Defining C Preprocessor Macro Libraries with Functional Programs. Computing and Informatics, Tome 35 (2017) no. 4, . http://gdmltest.u-ga.fr/item/cai3380/