FACTOID # 111: On average, more than 70 persons die of varicose veins per year per country.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Dynamic scoping
This article or section should be merged with scope (programming).

Dynamic variable scoping is when you scope a variable in a programming language by replacing the existing variable of that name with a new variable temporarily, for instance for the duration of a function call. This is an easy way to implement private variables. However the problem is that if one function calls another, the other may accidentally modify the first function's variables when it intended to modify a global variable instead. Therefore over time it is becoming more common for programming languages to implement private variables with lexical variable scoping instead.


For example, take this procedure in the Scheme programming language:

 (define foo (lambda () (let* ((x 5) (gimmex (lambda () x ))) (let* ((x 10)) (gimmex))))) 

gimmex will return 10 in dynamic scoping, and 5 in lexical scoping.


In dynamic scoping, gimmex would return 10, because when gimmex was called, x was defined to be 10. gimmex opens the procedure (lambda () x) to where the current environment is. In other words, variables that occur free in a procedure or subroutine would be looked up in the scope where the procedure was called.


  Results from FactBites:
 
MuLE Static versus Dynamic Scoping Lab (2472 words)
The concept of dynamic verses static scoping is concerned which set of rules to apply when finding a binding to a variable and/or changing a value bound to a variable.
Dynamic scoping rules depend on the calling sequence of the (sub)programs and requires searching the executing subprogram’s dynamic parent, i.e., the calling environment first.
If dynamic scoping rules were to continue to be followed, this is would be the correct environment to search next.
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m