Linear type system

Linear type system

A linear type system is a particular form of type system used in a programming language. Linear type systems allow references but not aliases. To enforce this, a reference goes out of scope after appearing on the right-hand side of an assignment, thus ensuring that only one reference to any object exists at once. Note that passing a reference as an argument to a function is a form of assignment, as the function parameter will be assigned the value inside the function, and therefore such use of a reference also causes it to go out of scope. Linear typing is related to uniqueness typing but is generally more restrictive.

A linear type system is similar to C++'s auto_ptr class, which behaves like a pointer but is invalidated by being set to null after use in an assignment. However, the linearity constraint can be checked at compile time, whereas auto_ptr can only raise exceptions at run time if it is misused.

Example code

This example uses C++-like notation, but shows a language with a linear type system (which therefore is "not" C++).

Dog* d = new Dog( name="Fido" ); // creates a reference to a new objectDog* p = d; // uses d to create a reference to the same object: this forces d out of scopeprint p->getName(); // output "Fido"print d->getName(); // COMPILE-TIME ERROR: d was forced out of scope by its use above and is not a valid variable here

Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Type system — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • Nominative type system — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • Saffron Type System — The Saffron Type System is a system for rendering high quality scalable type on digital displays. Developed by Mitsubishi Electric Research Laboritories (MERL), Saffron is built on a core of Adaptively Sampled Distance Field (ADF) technology.… …   Wikipedia

  • Argonne Tandem Linear Accelerator System — The Argonne Tandem Linac Accelerator System (ATLAS) is a scientific user facility at Argonne National Laboratory. ATLAS is the first superconducting linear accelerator for heavy ions at energies in the vicinity of the Coulomb barrier.The ATLAS… …   Wikipedia

  • Linear-motion bearing — A linear motion bearing or slide is a bearing designed to provide free motion in one dimension. There are many different types of linear motion bearings and this family of products is generally broken down into two sub categories: rolling element …   Wikipedia

  • Linear programming — (LP, or linear optimization) is a mathematical method for determining a way to achieve the best outcome (such as maximum profit or lowest cost) in a given mathematical model for some list of requirements represented as linear relationships.… …   Wikipedia

  • Linear immunoglobulin A dermatosis — Linear IgA dermatosis is a very rare autoimmune blistering disorder, which manifests via blistering of the skin and the mucous membranes. An autoimmune disorder is a malfunction of the body s immune system causing the body to attack its own… …   Wikipedia

  • Linear Flash — is a PC card flash memory format now used primarily in Cisco routers. Linear Flash requires no battery support, unlike somewhat faster SRAM, and features read/write speeds much faster than similar, less expensive ATA type cards (which include… …   Wikipedia

  • Type II topoisomerase — Type II topoisomerases cut both strands of the DNA helix simultaneously in order to change the linking number of the molecule. FunctionOnce cut, the ends of the DNA are separated, and a second DNA duplex is passed through the break. Following… …   Wikipedia

  • System of Physical Quantities — of Nikolay A. Plotnikov (SPQ) the classification of physical quantities or physical operators, that makes it possible to reveal their dependence on the geometry of space time and fundamental physical constants in the form of differential… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”