rfc:namespaceissues
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:namespaceissues [2008/10/15 20:26] – created cellog | rfc:namespaceissues [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Request for Comments: Namespace Issues and Greg's Solutions ====== | ====== Request for Comments: Namespace Issues and Greg's Solutions ====== | ||
- | * Version: 1.0 | + | * Version: 1.1.1 |
* Date: 2008-10-15 | * Date: 2008-10-15 | ||
* Author: Greg Beaver < | * Author: Greg Beaver < | ||
Line 15: | Line 15: | ||
1. conflict between namespaced functions and static class methods | 1. conflict between namespaced functions and static class methods | ||
2. resolving access to internal classes | 2. resolving access to internal classes | ||
+ | |||
+ | Contrary to the doom and gloom on php-internals, | ||
+ | |||
+ | My interest in this document is simply to point out the only remaining issues and how easy it is to solve them. None of the other solutions proposed (such as re-using -> for staticclass-> | ||
===== Conflict between namespaced functions and static class methods ===== | ===== Conflict between namespaced functions and static class methods ===== | ||
Line 41: | Line 45: | ||
one:: | one:: | ||
</ | </ | ||
+ | |||
==== The solutions ==== | ==== The solutions ==== | ||
Line 50: | Line 55: | ||
3. explicit disambiguation using "use namespace blah:: | 3. explicit disambiguation using "use namespace blah:: | ||
- | <code php> | + | <code php> |
- | | + | <?php |
- | | + | include ' |
- | | + | use namespace one:: |
- | | + | // this is now namespace one::step, function two |
- | | + | one:: |
- | | + | </ |
If the " | If the " | ||
+ | |||
+ | Note that existing code relying upon " | ||
+ | a naming conflict. | ||
4. disallow mixing namespaces and classes with the same name | 4. disallow mixing namespaces and classes with the same name | ||
- | === use ::: as primary namespace separator === | + | I prefer #2, but would be happy with #3 or #1. |
+ | |||
+ | ==== use ::: as primary namespace separator | ||
== pros == | == pros == | ||
Line 72: | Line 82: | ||
2. ::: is visually similar to :: so this::: | 2. ::: is visually similar to :: so this::: | ||
- | === use ::: as separator between namespace name and element === | + | ==== use ::: as separator between namespace name and element |
== pros == | == pros == | ||
Line 85: | Line 95: | ||
3. ::name would probably need to be changed to :::name for consistency. | 3. ::name would probably need to be changed to :::name for consistency. | ||
- | === explicit disambiguation with "use namespace blah:: | + | ==== explicit disambiguation with "use namespace blah:: |
== pros == | == pros == | ||
Line 99: | Line 109: | ||
could experience a performance slowdown. | could experience a performance slowdown. | ||
- | === disallow mixing namespaces and classes with the same name === | + | ==== disallow mixing namespaces and classes with the same name ==== |
== pros == | == pros == | ||
Line 179: | Line 189: | ||
This will be better for 99% of scripts, as evidenced by the ratio of internal vs. userspace classes (see http:// | This will be better for 99% of scripts, as evidenced by the ratio of internal vs. userspace classes (see http:// | ||
- | ===== Changelog | + | ===== Why Stas's proposed solution doesn' |
+ | [[rfc: | ||
+ | > New syntax for static access is introduced: using '' | ||
+ | < | ||
+ | ClassName-> | ||
+ | ClassName-> | ||
+ | ClassName-> | ||
+ | </ | ||
+ | |||
+ | Although this would in theory solve the ambiguity, it does not solve the ambiguity for all existing code, which as we know uses this syntax: | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | ClassName:: | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | In fact, this proposal would require every single reference to a static method or class constant to be rewritten as ClassName-> | ||
+ | |||
+ | The only fixes that can solve the problem are fixes that do **not** force PHP developers to rewrite code. Every proposal below would only require changes to as-yet-unwritten code. Solution #3 would in fact not even require changes to code written based on PHP 5.3alpha2. | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | * Version 1.1: add [[# | ||
+ | * Version 1.1.1: move Classname-> |
rfc/namespaceissues.1224102393.txt.gz · Last modified: 2017/09/22 13:28 (external edit)