I am wondering, from where static and dynamic scoping got their names.

After understanding the concept of static and dynamic scoping in C, what I assume is that whenever we failed to find out the declaration of the variable within the scope of the function than in order to resolve this name, we refer the global variable (which is declared at the time of compilation). As name resolution of a variable is done by a global variable which is declared at the time of compilation (static), therefore this scoping is called static scoping.

On the other hand, if the name of a variable is resolved by a dynamic variable (variable created at runtime) than it is called dynamic scoping.

Is this the reason why the static name is given to static scoping and dynamic to dynamic scoping?

  • 2
    $\begingroup$ You have a 'nearly` complete misunderstanding of static and there is no variable modifier dynamic Suggest reading the manual. There are several different reasons to use the modifier static. They all need to be understood when programng in C $\endgroup$ – user3629249 Nov 3 '18 at 3:07
  • 1
    $\begingroup$ I suggest you first ask "What is static and what is dynamic scoping of a variable?". (Note: C only has static scoping, what you are describing is incorrect understanding of C, as well as incorrect usage of terminology). $\endgroup$ – Andrej Bauer Nov 3 '18 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.