I could describe JQuery as a library that allows you to easily select elements on and traverse the DOM, the DOM would be the name of the tree or organizational structure of the HTML.

When you are describing what JS (or any other language) scope bubbles up from the local scope, to its parent scope, to its parent scope, to its parent scope, ...., until there are no more parent scopes, where you have reached the global Object scope, what would you call this scope organization?

  • $\begingroup$ In which way is this a computer science question? What do you need that name for? Are you familiar with the word "hierarchy"? $\endgroup$
    – Raphael
    Commented Nov 18, 2014 at 7:45
  • $\begingroup$ While it is a hierarchy, I am wondering if *this* specific hierarchy has a name. I will be referencing it several times in a scholarly article, and to my knowledge, this is not named. I feel that scope hierarchy or the like is not clear or definitive enough. $\endgroup$ Commented Nov 18, 2014 at 19:17
  • $\begingroup$ There is an old name that was created in part for that in old statically scoped languages, starting with Algol 60 (possibly Algol 58). It was called block structure, and the languages were referred to as block structured languages. But I do not know if this is still much in use. The concept of Block scope seems still in use. $\endgroup$
    – babou
    Commented Nov 18, 2014 at 21:05
  • 1
    $\begingroup$ What is the role of your first sentence, JQuery, DOM and HTML, in the question, since it is supposed to be scope "in any other language" too. $\endgroup$
    – babou
    Commented Nov 19, 2014 at 11:08
  • $\begingroup$ The purpose of the first sentence is to show that the particular hierarchy on the web is referred to as the DOM. other hierarchies we know of in CS are stack, heap, AR/ARIs, etc.... I am wondering what the name for the hierarchy that deals with scopes as the members in the organization. Simply saying 'I jump up one level of scope' doesn't seem clear enough given that there are different scoping structures. I want to say I moved up three levels on the X. What is X? $\endgroup$ Commented Nov 19, 2014 at 18:04

1 Answer 1


As Raphael says in his comment, this is a hierarchical scope organization. But this can qualified any kind of tree structured scope, and you state in the title that it is tree structured.

The whole purpose of this hierarchy is to allow reusing the same name in a different scope, for some other naming purpose. So, given a name, you have to decide where to lokk for its meaning, in what scope.

As you suggest, you start for the current scope (to be defined ...) and you buble up to parent scopes until you find a definition for that name (a declaration usually). The first one you find is usually supposed to be the right one.

But there is a major problem remaining: which is the parent scope of any given scope? There are two major policies regarding this: static scoping also called lexical scoping, and dynamic scoping.

Static scoping corresponds roughly to the way scopes are embedded according to the program text. Dynamic scoping corresponds to the way scopes are embedded according to program execution.

So, for example, take a function foo that is declared in your program. If defines a new scope, with the variables local to foo. If the function uses a variable x that it does not declare, the meaning of the variable must be found in the parent scope. For dynamic scoping, the parent scope is that of the scoping structure (function, method, module, and whatever creates new scopes) that called the function foo. For static scoping the parent scope is the scoping structure in which the function foo was declared.

Static scoping is usually preferred because the meaning of a programming construct is independent of where it is actually used (possibly many different places), and depends only of where it is defined (only one place). Hence program analysis, understanding, and maintenance is usually much easier with static scoping.

The story goes that dynamic scoping was invented more or less by accident, as it was used in the first Lisp interpreter in the late 1950s. People were not yet aware of the difference at the time. When they found out (see the Funarg controversy), the language was being used and it was to late. Until Scheme came in as a statistically scoped version of Lisp.

But there can be other ways of organizing scopes, of importing one scope into another, and so on. I suggest that you read the wikipedia page on scope, which you should have done before asking.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.