concepts

A Review of Static and Dynamic Scoping in Programming Languages

All programming languages allow names to be associated with values by means of definitions, and a name is said to be in the scope of its definition. When a name is mentioned in a program, its definition (if any) must be known, in order for its invocation to make sense. However, most languages allow names to be re-defined in a program – the rules for determining to which definition a name refers, are called the scoping rules.
There are two principal scoping methods: static and dynamic. This post will firstly explain these two concepts, comparing their similarities and differences. The uses of the two methods will be discussed, illustrating these with code from actual programming languages. Finally the essay will conclude with a critical summary of the pros and cons of static and dynamic scoping for present day programming problems.

Read More…

Call-by-reference vs. Call-by-value in programming

Generally speaking, in computer programming, a parameter is a special kind of variable, used in a function declaration to refer to one of the pieces of data provided as input to that function. These pieces of data, in turn, are called arguments. Therefore, in order to make a clear distinction between them, the argument is the actual value passed to a function, procedure, or method, whereas the parameter is a reference to that value inside the implementation of the function. The act of transmitting parameter values to and/or from a called function is known as “parameter passing”. The way that the arguments are evaluated and passed to the function depends on the programming language and the kind of parameter passing mechanisms it uses. Two very common mechanisms used in many programming languages are call-by-reference and call-by-value.

Read More…

 Scroll to top