Difference between 'scope' and 'namespace'?

Posted by katriel on Stack Overflow See other posts from Stack Overflow or by katriel
Published on 2014-06-12T15:20:43Z Indexed on 2014/06/12 15:24 UTC
Read the original article Hit count: 333

What is the difference, in general, between the concepts of namespaces and scope?

To my understanding, both describe the parts of a program in which a variable/object/method/function will be accessible. I understand that 'scope' tends to be a property of the variable (e.g., "This variable has global scope"), while a 'namespace' is a property of the program (e.g., "A Python function creates a local namespace"). Are there other differences?

Global scope vs global namespace addresses a slightly narrower question: global namespaces in C++. http://www.alan-g.me.uk/tutor/tutname.htm states,

There are a few very subtle differences between the terms but only a Computer Scientist pedant would argue with you, and for our purposes namespace and scope are identical.

What are those subtle differences? Under what circumstances or with which kinds of languages do people use each concept?

© Stack Overflow or respective owner

Related posts about namespaces

Related posts about scope