Hostname: page-component-76fb5796d-5g6vh Total loading time: 0 Render date: 2024-04-25T16:05:59.496Z Has data issue: false hasContentIssue false

Meta-programming through typeful code representation

Published online by Cambridge University Press:  06 October 2005

CHIYAN CHEN
Affiliation:
Computer Science Department, Boston University, Boston, MA, USA (email: chiyan@cs.bu.edu, hwxi@cs.bu.edu)
HONGWEI XI
Affiliation:
Computer Science Department, Boston University, Boston, MA, USA (email: chiyan@cs.bu.edu, hwxi@cs.bu.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

By allowing the programmer to write code that can generate code at run-time, meta-programming offers a powerful approach to program construction. For instance, meta-programming can often be employed to enhance program efficiency and facilitate the construction of generic programs. However, meta-programming, especially in an untyped setting, is notoriously error-prone. In this paper, we aim at making meta-programming less error-prone by providing a type system to facilitate the construction of correct meta-programs. We first introduce some code constructors for constructing typeful code representation in which program variables are represented in terms of deBruijn indexes, and then formally demonstrate how such typeful code representation can be used to support meta-programming. With our approach, a particular interesting feature is that code becomes first-class values, which can be inspected as well as executed at run-time. The main contribution of the paper lies in the recognition and then the formalization of a novel approach to typed meta-programming that is practical, general and flexible.

Type
Article
Copyright
2005 Cambridge University Press
Submit a response

Discussions

No Discussions have been published for this article.