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
Namespace
(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!
===Emulating namespaces=== In programming languages lacking language support for namespaces, namespaces can be emulated to some extent by using an [[identifier naming convention]]. For example, [[C (programming language)|C]] libraries such as [[libpng]] often use a fixed prefix for all functions and variables that are part of their exposed interface. Libpng exposes identifiers such as: png_create_write_struct png_get_signature png_read_row png_set_invalid This [[naming conventions (programming)|naming convention]] provides reasonable assurance that the [[identifier]]s are unique and can therefore be used in larger programs without [[naming collision]]s.<ref>{{Cite web|url=http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=286 |title=Why I Hate Namespaces |author=Danny Kalev |url-status=bot: unknown |archive-url=https://web.archive.org/web/20160709115609/http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=286 |archive-date=2016-07-09 }}</ref> Likewise, many packages originally written in [[Fortran]] (e.g., [[BLAS]], [[LAPACK]]) reserve the first few letters of a function's name to indicate the group to which the function belongs. This technique has several drawbacks: * It doesn't scale well to nested namespaces; identifiers become excessively long since all uses of the identifiers must be [[fully qualified name|fully namespace-qualified]]; * Individuals or organizations may use inconsistent naming conventions, potentially introducing unwanted obfuscation; * Compound or "query-based" operations on groups of identifiers, based on the namespaces in which they are declared, are rendered unwieldy or unfeasible; * In languages with restricted identifier length, the use of prefixes limits the number of characters that can be used to identify what the function does; this is a particular problem for packages originally written in [[Fortran|FORTRAN 77]], which offered only 6 characters per identifier; for example, the name of the [[BLAS]] function <code>DGEMM</code> indicates that it operates on double-precision floating-point numbers (<code>D</code>) and general matrices (<code>GE</code>), with only the last two characters (<code>MM</code>) showing what it actually does: matrix–matrix multiplication. It also has a few advantages: * No special software tools are required to locate names in source-code files; a simple program like [[grep]] suffices; * There are no namespace-related name conflicts; * There is no need for name mangling, and thus no potential incompatibility problems.
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
Namespace
(section)
Add topic