Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Scope (computer science)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Qualified names == As we have seen, one of the key reasons for scope is that it helps prevent name collisions, by allowing identical names to refer to distinct things, with the restriction that the names must have separate scopes. Sometimes this restriction is inconvenient; when many different things need to be accessible throughout a program, they generally all need names with global scope, so different techniques are required to avoid name collisions. To address this, many languages offer mechanisms for organizing global names. The details of these mechanisms, and the terms used, depend on the language; but the general idea is that a group of names can itself be given a name β a prefix β and, when necessary, an entity can be referred to by a ''qualified name'' consisting of the name plus the prefix. Normally such names will have, in a sense, two sets of scopes: a scope (usually the global scope) in which the qualified name is visible, and one or more narrower scopes in which the ''unqualified name'' (without the prefix) is visible as well. And normally these groups can themselves be organized into groups; that is, they can be ''nested''. Although many languages support this concept, the details vary greatly. Some languages have mechanisms, such as ''namespaces'' in [[C++]] and [[C Sharp (programming language)|C#]], that serve almost exclusively to enable global names to be organized into groups. Other languages have mechanisms, such as ''packages'' in [[Ada (programming language)|Ada]] and ''structures'' in [[Standard ML]], that combine this with the additional purpose of allowing some names to be visible only to other members of their group. And object-oriented languages often allow classes or singleton objects to fulfill this purpose (whether or not they ''also'' have a mechanism for which this is the primary purpose). Furthermore, languages often meld these approaches; for example, [[Perl]]'s packages are largely similar to C++'s namespaces, but optionally double as classes for object-oriented programming; and [[Java (programming language)|Java]] organizes its variables and functions into classes, but then organizes those classes into Ada-like packages.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Scope (computer science)
(section)
Add topic