rfc:namespaceref

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:namespaceref [2008/10/14 21:13] stasrfc:namespaceref [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Request for Comments: How to write RFCs ======+====== Namespace refinement proposals ======
   * Version: 1.0   * Version: 1.0
   * Date: 2008-03-06   * Date: 2008-03-06
Line 17: Line 17:
  
 Inside namespace, class definition can be used as: Inside namespace, class definition can be used as:
-  - Imported name - name mentioned in "use" statement as sortcut for the full name. Imported name can be also a prefix to further qualified name.+  - Imported name - name mentioned in "use" statement as shortcut for the full name. Imported name can be also a prefix to further qualified name.
 <code php> <code php>
 use Foo::Bar as Fubar; use Foo::Bar as Fubar;
 $a = new Fubar::Baz(); $a = new Fubar::Baz();
 </code> </code>
-  - Full name not mentioned in import - Foo::Bar::Baz - take at the face value. Special cases of this are: +  - Full name not mentioned in import - ''Foo::Bar::Baz'' - take at the face value. Special cases of this are: 
-    - ::Foo - global name +    - ''::Foo'' - global name, i.e. explicit reference to non-namespaced class inside namespace 
-    - namespace::Foo - name explicitly referring to current namespace +    - ''namespace::Foo'' - name explicitly referring to current namespace 
-  - Unqualified name 'Foonot mentioned in import - resolved as namespace::Foo.+  - Unqualified name "Foonot mentioned in import - resolved as ''namespace::Foo''.
  
 ==== Pro ==== ==== Pro ====
Line 50: Line 50:
 Constants resolved in a way identical to functions.  Constants resolved in a way identical to functions. 
  
-New syntax for static access is introduced: using Name->Member is the same as Name::Member, e.g.:+New syntax for static access is introduced: using ''Name->Member'' is the same as ''Name::Member'', e.g.:
 <code> <code>
 ClassName->Foo() - static method call ClassName->Foo() - static method call
Line 56: Line 56:
 ClassName->Foo - class constant access ClassName->Foo - class constant access
 </code> </code>
 +
 +==== Pro ====
 +  * The last syntax allows to call static methods unambiguously
 +  * Functions and constants supported
 +
 +==== Contra ====
 +  * The model is more complex and may be confusing for the new users.
 +  * Unqualified name resolutions for classes and functions/constants are slightly different due to the different usage patterns.
 +  * New syntax for static access
  
 ===== See also ===== ===== See also =====
rfc/namespaceref.1224018787.txt.gz · Last modified: 2017/09/22 13:28 (external edit)