Namespace (namespace)

Namespace altogether divided into three types :
       Global namespace
       Local namespace
       Built-in namespace
 
Namespaces
      When the program runs, the code read from top to bottom once encountered variables and values, # he will open up a space in memory to store correspondence between the memory address of variables and values, so the storage space correspondence between variables and worth called the namespace (namespace).
 
The local name space
      When the interpreter encounters function, he would function name is stored in memory, but for all working off heart function body. # When a function is executed, he will find the body of a function by function name, and the correspondence between the function body variables stored in a temporary # open space, with the end of the function, temporarily closed space, this space is called temporary name space (local name space)
 
Scope
Scope is the scope, the range can be divided into force in accordance with global scope and local scope.
Global scope:
     Includes built-in namespace, global namespace can be referenced anywhere in the entire file, globally effective
The local scope:
      The local name space, can only take effect in the local area
 
Load order:
      1, built-in namespace (before running load) ->
      2, global namespace (program execution: from top to bottom loading) ->
      3, local namespace (run-time function: when the call load)
 
Sequence values: from inside to outside, to find the one-way
      In the local call: local namespace -> global namespace -> Built-namespace
      In a global call: global namespace -> Built-namespace

Guess you like

Origin www.cnblogs.com/computer123/p/11799733.html