Static Scope

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.






Jenna Phipps
Jenna Phipps is a contributor for websites such as Webopedia.com and Enterprise Storage Forum. She writes about information technology security, networking, and data storage. Jenna lives in Nashville, TN.

Top Articles

The Complete List of 1500+ Common Text Abbreviations & Acronyms

Text Abbreviations reviewed by Web Webster   From A3 to ZZZ we list 1,559 SMS, online chat, and text abbreviations to help you translate and understand...

Windows Operating System History & Versions

The Windows operating system (Windows OS) refers to a family of operating systems developed by Microsoft Corporation. We look at the history of Windows...

How to Create a Website Shortcut on Your Desktop

Website Shortcut on Your Desktop reviewed by Web Webster   This Webopedia guide will show you how to create a website shortcut on your desktop using...

Generations of Computers (1st to 5th)

Reviewed by Web Webster Learn about each of the 5 generations of computers and major technology developments that have led to the computing devices that...

Pareto Principle

The Pareto Principle holds that 80 percent of consequences can come from 20...

Thumb Drive

A thumb drive, or USB flash drive, is a small device with flash...

Pipeline

A pipeline is a figurative measurement of client or customer progress through a...