Multi-stage programming (MSP) is a variety of
metaprogramming
Metaprogramming is a computer programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyse, or transform other programs, and even modi ...
in which compilation is divided into a series of intermediate phases, allowing
typesafe run-time code generation.
Statically defined types are used to verify that dynamically constructed types are valid and do not violate the type system.
In MSP languages, expressions are qualified by notation that specifies the phase at which they are to be evaluated. By allowing the specialization of a program at run-time, MSP can optimize the performance of programs: it can be considered as a form of
partial evaluation that performs computations at compile-time as a trade-off to increase the speed of run-time processing.
Multi-stage programming languages support constructs similar to the
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
construct of quotation and
eval
, except that
scoping rules are taken into account.
References
{{reflist
External links
MetaOCaml
Programming paradigms
Type systems