Scope (computer science) in the context of Code block


Scope (computer science) in the context of Code block

Scope (computer science) Study page number 1 of 1

Play TriviaQuestions Online!

or

Skip to study material about Scope (computer science) in the context of "Code block"


⭐ Core Definition: Scope (computer science)

In computer programming, the scope of a name binding (an association of a name to an entity, such as a variable) is the part of a program where the name binding is valid; that is, where the name can be used to refer to the entity. In other parts of the program, the name may refer to a different entity (it may have a different binding), or to nothing at all (it may be unbound). Scope helps prevent name collisions by allowing the same name to refer to different objects – as long as the names have separate scopes. The scope of a name binding is also known as the visibility of an entity, particularly in older or more technical literature—this is in relation to the referenced entity, not the referencing name.

The term "scope" is also used to refer to the set of all name bindings that are valid within a part of a program or at a given point in a program, which is more correctly referred to as context or environment.

↓ Menu
HINT:

👉 Scope (computer science) in the context of Code block

In computer programming, a block of source code is a grouping of statements that execute in sequential order, top to bottom. The block structure is fundamental to structured programming, where control structures are formed with blocks. Syntactically, a block acts much like a single statement in that a control structure generally operates either on a single statement or a block.

The nature of a block varies by programming language, but there are typical features. A block usually provides for visibility scope such that an identifier defined in a block is not visible in outer, containing blocks, but is visible in inner, nested blocks unless it is masked by an identifier with the same name. A block usually provides for lifetime scope such that resources associated with an identifier are partially or fully released when control flow reaches the end of the block in which the identifier was defined.

↓ Explore More Topics
In this Dossier

Scope (computer science) in the context of Scheme (programming language)

Scheme is a dialect of the Lisp family of programming languages. Scheme was created during the 1970s at the MIT Computer Science and Artificial Intelligence Laboratory (MIT CSAIL) and released by its developers, Guy L. Steele and Gerald Jay Sussman, via a series of memos now known as the Lambda Papers. It was the first dialect of Lisp to choose lexical scope and the first to require implementations to perform tail-call optimization, giving stronger support for functional programming and associated techniques such as recursive algorithms. It was also one of the first programming languages to support first-class continuations. It had a significant influence on the effort that led to the development of Common Lisp.

The Scheme language is standardized in the official Institute of Electrical and Electronics Engineers (IEEE) standard and a de facto standard called the Revised Report on the Algorithmic Language Scheme (RnRS). A widely implemented standard is R5RS (1998). The most recently ratified standard of Scheme is "R7RS-small" (2013). The more expansive and modular R6RS was ratified in 2007. Both trace their descent from R5RS; the timeline below reflects the chronological order of ratification.

View the full Wikipedia page for Scheme (programming language)
↑ Return to Menu

Scope (computer science) in the context of Automatic variable

In computer programming, an automatic variable is a local variable which is allocated and deallocated automatically when program flow enters and leaves the variable's scope. The scope is the lexical context, particularly the function or block in which a variable is defined. Local data is typically (in most languages) invisible outside the function or lexical context where it is defined. Local data is also invisible and inaccessible to a called function, but is not deallocated, coming back in scope as the execution thread returns to the caller.

Automatic local variables primarily applies to recursive lexically scoped languages. Automatic local variables are normally allocated in the stack frame of the procedure in which they are declared. This was originally done to achieve re-entrancy and allowing recursion, a consideration that still applies today. The concept of automatic variables in recursive (and nested) functions in a lexically scoped language was introduced to the wider audience with ALGOL in the late 1950s, and further popularized by its many descendants.

View the full Wikipedia page for Automatic variable
↑ Return to Menu

Scope (computer science) in the context of Name binding

In programming languages, name binding is the association of entities (data and/or code) with identifiers. An identifier bound to an object is said to reference that object. Machine languages have no built-in notion of identifiers, but name-object bindings as a service and notation for the programmer is implemented by programming languages. Binding is intimately connected with scoping, as scope determines which names bind to which objects – at which locations in the program code (lexically) and in which one of the possible execution paths (temporally).

Use of an identifier id in a context that establishes a binding for id is called a binding (or defining) occurrence. In all other occurrences (e.g., in expressions, assignments, and subprogram calls), an identifier stands for what it is bound to; such occurrences are called applied occurrences.

View the full Wikipedia page for Name binding
↑ Return to Menu

Scope (computer science) in the context of ALGOL 58

ALGOL 58, originally named IAL, is a member of the ALGOL family of computer programming languages. It was an early compromise design soon superseded by ALGOL 60. According to John Backus:

ALGOL 58 introduced the fundamental notion of the compound statement, but it was restricted to control flow only, and it was not tied to identifier scope in the way that Algol 60's blocks were.

View the full Wikipedia page for ALGOL 58
↑ Return to Menu