rfc:namespaceref
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:namespaceref [2008/10/14 20:49] – created stas | rfc:namespaceref [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
* Version: 1.0 | * Version: 1.0 | ||
* Date: 2008-03-06 | * Date: 2008-03-06 | ||
Line 6: | Line 6: | ||
* First Published at: http:// | * First Published at: http:// | ||
- | This RFC is a template other people can use to write their own RFCs. | + | The purpose of the RFC is to summaries current proposals regarding namespaces. |
+ | |||
===== Introduction ===== | ===== Introduction ===== | ||
- | The purpose of RFCs are to work collaboratively towards | + | So far I have two proposals for resolving current namespace debates - one that includes namespaced function and one that does not. This RFC assumes you are familiar with the topic of namespaces in general. |
+ | |||
+ | ===== Namespaces without functions/ | ||
+ | |||
+ | All new functionality relates only to classes. Any code is allowed inside namespace, but only class definitions and references to classes is influenced by it. Class defined in the namespace is prefixed by it's name. | ||
+ | |||
+ | Inside namespace, class definition can be used as: | ||
+ | - Imported name - name mentioned in " | ||
+ | <code php> | ||
+ | use Foo::Bar as Fubar; | ||
+ | $a = new Fubar:: | ||
+ | </ | ||
+ | - Full name not mentioned in import - '' | ||
+ | - '':: | ||
+ | - '' | ||
+ | - Unqualified name " | ||
+ | |||
+ | ==== Pro ==== | ||
+ | * Most (not all, I know, but most) of the use cases for namespaces are in the OO realm, | ||
+ | * Everything becomes so much simpler with only classes. Classes and functions have very different usage patterns in PHP, so if we try to serve them both we inevitably encounter some " | ||
+ | ==== Contra ==== | ||
+ | Well, duh, no functions :) | ||
- | ==== Why do we need RFCs? ==== | + | ===== Namespaces with functions/ |
- | They serve to keep a summary of on going discussions. This way people can keep an overview of the state of the discussion. Even if never put into place in the end, they also serve as a historical log of discussions that is much easier to read compared to mailinglist threads. | + | As the above, plus: |
- | ===== Common Misconceptions ===== | + | Functions and constants defined in the namespace are prefixed with the namespace name. |
- | RFCs do not in any way replace discussions on the mailing list. | + | Quailified function call '' |
+ | - All possible " | ||
+ | - If function by name " | ||
+ | - Otherwise, treat the call as call to method " | ||
- | ===== Proposal and Patch ===== | + | Unqualified function call '' |
+ | - If internal function " | ||
+ | - Otherwise, call the function '' | ||
- | Nothing needs to be patched here. Just use this template at your discretion. | + | Constants resolved in a way identical |
- | ==== Rejected Features ==== | + | New syntax for static access is introduced: using '' |
+ | < | ||
+ | ClassName-> | ||
+ | ClassName-> | ||
+ | ClassName-> | ||
+ | </ | ||
- | Automated voting system. | + | ==== Pro ==== |
+ | * The last syntax allows to call static methods unambiguously | ||
+ | * Functions and constants supported | ||
- | ==== More about RFCs ==== | + | ==== Contra |
+ | * The model is more complex and may be confusing for the new users. | ||
+ | * Unqualified name resolutions for classes and functions/ | ||
+ | * New syntax for static access | ||
- | http:// | + | ===== See also ===== |
- | ===== Changelog ===== | + | Please see also [[http:// |
rfc/namespaceref.1224017367.txt.gz · Last modified: 2017/09/22 13:28 (external edit)