rfc:namespaceresolution
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:namespaceresolution [2008/10/30 10:51] – created lsmith | rfc:namespaceresolution [2008/10/30 12:00] – lsmith | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
* Version: 0.9 | * Version: 0.9 | ||
* Date: 2008-10-30 | * Date: 2008-10-30 | ||
Line 14: | Line 14: | ||
==== Why do we need RFCs? ==== | ==== Why do we need RFCs? ==== | ||
- | Obviously its important that we make a conscious decision for these questions. Depending on how we approach this, users might unintentionally trigger | + | Obviously its important that we make a conscious decision for these questions. Depending on how we approach this, users might unintentionally trigger |
===== Possible approaches ===== | ===== Possible approaches ===== | ||
Line 27: | Line 27: | ||
In the past people created classes often for the sole reason of being able to sort of " | In the past people created classes often for the sole reason of being able to sort of " | ||
- | One noteworthy aspect here is that for classes we have __autoload(). If non fully qualified identifiers can be used to reference global identifiers, | + | One noteworthy aspect here is that for classes we have autoload. If non fully qualified identifiers can be used to reference global identifiers, |
- | For functions however we do not have __autoload() | + | For functions however we do not have autoload |
At the same time the ability to automatically fallback into the global namespace gives the ability to overload global identifiers inside a namespace without having to modify existing code inside that namespace. This however can also be considered dangerously similar to the ambiguity issues we solved by changing the namespace separator. Static code analysis becomes more difficult, which is always the cost of overloading. | At the same time the ability to automatically fallback into the global namespace gives the ability to overload global identifiers inside a namespace without having to modify existing code inside that namespace. This however can also be considered dangerously similar to the ambiguity issues we solved by changing the namespace separator. Static code analysis becomes more difficult, which is always the cost of overloading. | ||
- | Further more users need to be aware that if they are overloading internal identifiers that they to make sure that either the relevant code is loaded. For classes there is the __autoload() | + | Further more users need to be aware that if they are overloading internal identifiers that they to make sure that either the relevant code is loaded. For classes there is the autoload |
One approach to make it at least noticeable when a fallback into the global namespace occurs would be to for example throw an E_NOTICE. This would obviously discourage users from using the fallback for overloading, | One approach to make it at least noticeable when a fallback into the global namespace occurs would be to for example throw an E_NOTICE. This would obviously discourage users from using the fallback for overloading, | ||
Line 56: | Line 56: | ||
== Advantages == | == Advantages == | ||
- Does not require fully qualified names for functions (and constants) | - Does not require fully qualified names for functions (and constants) | ||
- | - No performance " | + | - No performance " |
- Ability to overload global functions (and constants) | - Ability to overload global functions (and constants) | ||
Line 76: | Line 76: | ||
== Disadvantages == | == Disadvantages == | ||
- Functions (and constants) still need fully qualified names | - Functions (and constants) still need fully qualified names | ||
- | - Possible performance bomb with __autoload() | + | - Possible performance bomb with autoload |
=== Only for internal identifiers === | === Only for internal identifiers === | ||
Line 106: | Line 106: | ||
== Disadvantages == | == Disadvantages == | ||
- There is overhead for the fallback | - There is overhead for the fallback | ||
- | - Additionally there is a possible performance bomb with __autoload() | + | - Additionally there is a possible performance bomb with autoload |
- Overloading global identifiers requires ensuring that all relevant files are loaded or unexpected behavior might occur | - Overloading global identifiers requires ensuring that all relevant files are loaded or unexpected behavior might occur | ||
Line 119: | Line 119: | ||
- Require fully qualified names for all global identifiers | - Require fully qualified names for all global identifiers | ||
- | ==== More about RFCs ==== | + | ==== More about namespaces |
- | http://en.wikipedia.org/wiki/Request_for_Comments | + | http://wiki.php.net/rfc/backslashnamespaces |
===== Changelog ===== | ===== Changelog ===== |
rfc/namespaceresolution.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1