The very simplified concept of Binding in programming languages

At the vary basic, binding is assigning one thing to another, usually, values to variables either by explicit declaration or implicit declaration.
For the newbies in programming, the terms, explicit and implicit declaration seems daunting its really not. Explicit declaration simply implies a statement that defines the variable name and it’s type e.g

public int i;

Enter fullscreen mode Exit fullscreen mode

while in implicit, the default convention is implemented e.g

int i;

Enter fullscreen mode Exit fullscreen mode

it assumes it is public.
Binding int a, b = 0; can occur at run-time or at compilation time, when it happens at run-time, the current state of the variable is changed in that a value is assigned to it. For instance

int a, b = 0, c;
    for(a = 0; a < 10; a++){
        b+=c;
    }

Enter fullscreen mode Exit fullscreen mode

the state of c changes as values are been added as the for loop is being executed.
Types of Binding
Dynamic Binding : Variable are bound to a type depending on the value assigned.
this happens at run-time.
Static Binding : This happens at compile time where the compiler figures out what variable to assign to what method or function. A perfect example is method overloading where two methods have same name but different number or type of parameter. If two parameters are passed in a method A (that has two parameters), the compiler figures out that the method to return is A.
Hope this helps.

原文链接:The very simplified concept of Binding in programming languages

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容