retagged by
623 views
0 votes
0 votes
What is referential transparency?
retagged by

1 Answer

1 votes
1 votes

A context in a sentence is "referentially transparent" if replacing a term in that context by another term that refers to the same entity doesn't alter the meaning.

So in order to understand the meaning of the above line we have to understand what is meant by  context

Firstly, take a sentence like “Lucifer is bigger than a mouse” and erase the word “Lucifer” to leave a blank –

ie. “_____ is bigger than a mouse”. This line is called a context.

We can fill the blank in the context to get a meaningful sentence.

Now we can fill the blank with the words that have same meaning like

Blue whale or earth's largest animal

if you put any one of  the above two in the sentence then the meaning of the sentence will not change.

 Blue whale is bigger than a mouse

Earth's largest animal is bigger than a mouse

This is called referential integrity

  a CONTEXT is “referentially transparent” if we can fill the blank with different names for the same underlying thing without affecting the meaning of the sentence.


In programming, an expression is called referentially transparent if it can be replaced with its corresponding value without changing the program's behavior.

For eg:-

In C, for incrementing a value we can do x++ or ++x or x=x+1 i.e. they are doing the same thing but when we use them in a context i.e in a code like

y=x++;

or

y = ++x;

the meaning of the sentence will change i.e. they are not following referntial integrity.

but if we write

y= ++x;

or

y = x+1;

Both will give same result so these two codes follow referntial transparency.

 

 

Related questions

7 votes
7 votes
3 answers
2
go_editor asked Dec 20, 2016
1,257 views
Are the two digraphs shown in the above figure isomorphic? Justify your answer.
1 votes
1 votes
1 answer
3
go_editor asked Dec 20, 2016
561 views
Verify whether the following mapping is a homomorphism. If so, determine its kernel.$f(x)=x^3$, for all $x$ belonging to $G$.
2 votes
2 votes
0 answers
4
go_editor asked Dec 20, 2016
485 views
Verify whether the following mapping is a homomorphism. If so, determine its kernel.$\overline{G}=G$