Referential Transparency

In computer programming, a referentially transparent function is one that, given the same parameter(s), it always returns the same result. While in mathematics all functions are referentially transparent, in programming this is not always the case. For example, take a "function" that takes no parameters and returns input from the keyboard. A call to this function may be GetInput(). The return value of GetInput() depends on what the user feels like typing in, so multiple calls to GetInput() with identical parameters (the empty list) may return different results. A more subtle example is that of a "function" that uses a global variable to help it compute its results. Since this variable is not passed as a parameter but can be altered, the results of subsequent calls to the function can differ even if the parameters are identical. Referential transparency is important because it allows the programmer to reason about program behavior. This can help in proving correctness, finding bugs that could not be found by testing, simplifying the algorithm, assisting in modifying the code without breaking it, or optimizing the code (by means of memoization). Some functional programming languages enforce referential transparency for all functions.

 

<< PreviousWord BrowserNext >>
rudolph pariser
rendezvous with rama
rust
real analysis
richie benaud
radio project
religious pluralism
roulette
reference counting
red eye effect
ramsay hunt syndrome
race and intelligence
retirement
realism
rc 135 rivet joint
rumiko takahashi
robbie coltrane
reformed presbyterian church of north america
riverside
reverse polish notation
roald hoffmann
rhotic consonant
richard hell
rob roy cocktail
rob roy
rogue
reaganomics
roland corporation
rhys ap gruffydd
rachel summers
richard of st. victor
rose
roman curia
romano mussolini
repo man
ruth benedict
reichstag
ruslan khasbulatov
rugby union six nations championship
reconquista
raku
roy orbison
ragtime
redmond