Changes

Jump to navigation Jump to search
Created page with ''''Reification''' is a concept in functional programming specifically concerned with the implementation of lazy evaluation by the suspension of a computation in a...'
'''Reification''' is a concept in [[functional programming]] specifically concerned with the implementation of [[lazy evaluation]] by the [[suspension]] of a [[computation]] in a [[lambda]].

Suppose we wish to compute the value of "x+y" in a [[lazy]] functional programming language such as [[Haskell]] or [[Nero]]. This is done with the functional expression <code>(+ x y)</code>. However, if the value of <code>y</code> is <code>nil</code> or perhaps unknown in the current [[context]], this expression will [[segmentation fault|segfault]]. Furthermore, the operation <code>+</code> may be expensive, for example if it represents [[string]] concatenation. Therefore, it is useful to wrap the computation in a [[lambda]], like so: <code>(if (nor (isNil x) (isNil y)) (+ x y) else (yield))</code>. This "wrapping" process is referred to in the [[literature]] as "ification", since a lambda is fundamentally equivalent to an <code>if</code> in functional languages.

Ification (a special case of [[lambda lifting]]) prevents the premature evaluation of the wrapped computation. However, it doesn't do anything to ensure lazy computation &mdash; that is, the computation might be evaluated safely but unnecessarily. Therefore, a second lambda is placed around the computation, this time to ensure that the computation is never performed ''until'' and ''unless'' it absolutely needs to be. This second lambda-lifting step is performed quietly behind the scenes in lazy languages such as Nero, but conceptually it looks like this: <code>(if (result_requested) if (nor (isNil x) (isNil y)) (+ x y) else2 (yield))</code>. This second step is referred to as "reification", and it is where lazy languages like Haskell derive most of their power.

[[Category:Computer Programming]]
2

edits

Navigation menu