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
Jenna Phipps is a writer for Webopedia.com, Enterprise Storage Forum, and CIO Insight. She covers data storage systems and data management, information technology security, and enterprise software solutions.

Related Articles

@ Sign

Pronounced at sign or simply as at, this symbol is used in e-mail addressing to separate the user' name from the user's domain name,...

Munging

(MUHN-jing) Munging (address munging), is the act of altering an email address posted on a Web page to make it unreadable to bots and...

How to Create an RSS Feed

In the second installment of RSS how-to, we look at some of the nonrequired (optional) channel and item tags, discuss RSS specifications in-depth and...

Dictionary Attack

(n.) (1) A method used to break security systems, specifically password-based security systems, in which the attacker systematically tests all possible passwords beginning with...

ScalaHosting

ScalaHosting is a leading managed hosting provider that offers secure, scalable, and affordable...

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their...

Best Managed Service Providers...

In today's business world, managed services are more critical than ever. They can...