Phase distinction

Phase Distinction is a property of programming languages that observe a strict division between types and terms. A concise rule for determining whether phase distinction is preserved in a language or not has been proposed by Luca Cardelli - If A is a compile-time term and B is a subterm of A, then B must also be a compile-time term. [1]

Most statically typed languages conform to the principle of phase distinction. However, some languages with especially flexible and expressive type systems (notably dependently typed programming languages) allow types to be manipulated in the same ways as regular terms. They may be passed to functions or returned as results.

A language with phase distinction may have separate namespaces for types and run-time variables. In an optimizing compiler, phase distinction marks the boundary between expressions which are safe to erase.

Theory

Phase distinction is used in conjunction with static checking.[2] By using a calculus based system, phase distinction removes the need to enforce linear logic between different types and terms of programming.[3]

Introduction

Phase Distinction distinguishes between processing to be done at compile-time versus processing done at runtime.

Consider a simple language,[3] with terms:

   t ::= true | false | x | λx : T . t | t t | if t then t else t

and types:

   T ::= Bool | T -> T 

Note how types and terms are distinct. At compile time, types are used to verify the validity of the terms. However, types do not play any role at runtime.

gollark: I don't want to use Python because it'd just devolve into the incomprehensible mess which Minoteaur and RSAPI are. Rust is, and as previously mentioned. Nim would require me to copypaste my random utility libraries all over the place and they'd be bad.
gollark: Besides, the issue isn't web, it's all programming languages ever.
gollark: Says the developer of Macron.
gollark: But hardware is designed with programming languages.
gollark: Generate the HTML on-demand with GPT or something, you mean?

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.