Dynamic Scope

Dynamic scope in programming mentions and defines variables depending on how recently that variable was called. Dynamic scope is a rarity in programming; static, or lexical, scoping is the norm. Static scope, the area in which a variable has a certain value, depends on the logical structure and organization of the program. 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.

In contrast, dynamic scope would use the most recent definition of x that had been called, even if it did not make lexical sense. The last value of x that was assigned in the program’s run time would then belong to the variable. The program pulls the most recent variable definition from the call stack, which is a compiled list of the most recent functions in the program.

An important note about scope: it can also refer to the way variables are used within the program, not just the local area in which they exist. Because scope indicates the area covered, not the action performed, it is not the most accurate term. But developers understand it to mean also the definition and usage of the variable.






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 1559 Common Text Abbreviations & Acronyms

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

List of Windows Operating System Versions & History [In Order]

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...

Glassdoor

Glassdoor is an online job search and review platform for people seeking new...

GitLab

GitLab is a DevOps platform where software development and IT operations teams collaborate...

Udemy

Udemy is a massive open online course (MOOC) platform offering a range of...