dcsimg
Main » TERM » S »

Static Scope Definition & Meaning

Static scope in programming declares variables lexically, depending on the logical structure and organization of the program. In programming, scope declares a range in which a variable is visible and usable. Scope is useful because it differentiates sections of a program and the variables within them.

One other note about scope is that its description is somewhat misleading: it also refers to the way a variable functions within a program, not just the area where it exists. Scope is not the most accurate term because it indicates only the area covered, not the action performed. Developers and researchers accept this and understand scope to mean both the definition and usage of a variable.

Static vs. dynamic scoping

Static scoping is common in programming languages; dynamic scope, the other form of scoping, is much less so. In static scoping, if an area of the program has a certain scope, a variable within a function will return its assigned value for that scope whenever the function runs. For example, if a variable x = 5 in a given function, and a subsequent conditional definition for x is also provided, x = 5 wherever the program's scope defines it as such. This is standard for most programming languages.

This is unlike dynamic scoping, which calls the most recently used value of a variable based on the program's call stack. In the above example, if x = 5 but then x was later defined with a value of 10, a program with a dynamic scope would call x = 10 if that value had been most recently used. Dynamic scope is less logical and structured than static scope.










LATEST ARTICLES
Texting & Chat Abbreviations

From A3 to ZZZ we list 1,559 text message and online chat abbreviations to help you translate and understand today's texting lingo. Includes Top... Read More »

Huge List of Computer Certifications

Have you heard about a computer certification program but can't figure out if it's right for you? Use this handy list to help you decide. Read More »

STUDY GUIDES
Computer Architecture Study Guide

Computer architecture provides an introduction to system design basics for most computer science students. Read More »

Network Fundamentals Study Guide

Networking fundamentals teaches the building blocks of modern network design. Learn different types of networks, concepts, architecture and... Read More »

The Five Generations of Computers

Learn about each of the five generations of computers and major technology developments that have led to the computing devices that we use... Read More »