Why binding is not a native feature in most of the languages?
- by Gulshan
IMHO binding a variable to another variable or an expression is a very common scenario in mathematics. In fact, in the beginning, many students think the assignment operator(=) is some kind of binding. But in most of the languages, binding is not supported as a native feature. In some languages like C#, binding is supported in some cases with some conditions fulfilled.
But IMHO implementing this as a native feature was as simple as changing the following code-
int a,b,sum;
sum := a + b;
a = 10;
b = 20;
a++;
to this-
int a,b,sum;
a = 10;
sum = a + b;
b = 20;
sum = a + b;
a++;
sum = a + b;
Meaning placing the binding instruction as assignments after every instruction changing values of any of the variable contained in the expression at right side. After this, trimming redundant instructions (or optimization in assembly after compilation) will do.
So, why it is not supported natively in most of the languages. Specially in the C-family of languages?
Update:
From different opinions, I think I should define this proposed "binding" more precisely-
This is one way binding. Only sum is bound to a+b, not the vice versa.
The scope of the binding is local.
Once the binding is established, it cannot be changed. Meaning, once sum is bound to a+b, sum will always be a+b.
Hope the idea is clearer now.
Update 2:
I just wanted this P# feature. Hope it will be there in future.