doc:scratchpad:namespacefaq

Differences

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

Link to this comparison view

Next revision
Previous revision
doc:scratchpad:namespacefaq [2008/10/28 11:51]
lsmith created
doc:scratchpad:namespacefaq [2017/09/22 13:28] (current)
Line 9: Line 9:
  
 Q: Would removing constants/​functions from namespaces make it possible to stick with "::"​ for namespaces? Q: Would removing constants/​functions from namespaces make it possible to stick with "::"​ for namespaces?
 +
 +A: Yes, but at a cost. Functions and constants within namespaced files would throw a fatal error. [Reference needed]
  
 Q: Was the "::"​ separator was dropped because of limitations on the Zend Engine? Q: Was the "::"​ separator was dropped because of limitations on the Zend Engine?
  
 Q: Was the fact that the "​\"​ character is harder to type on various international keyboards considered and if so why was this character still chosen? Q: Was the fact that the "​\"​ character is harder to type on various international keyboards considered and if so why was this character still chosen?
 +
 +A: Yes, it was considered. However the fact that "​\"​ is already used in PHP means that nobody has a keyboard that actually lacks that character. There are also workarounds for those facing difficulties. [References needed]
  
 Q: Why was character combination XYZ (":::",​ "​@"​ etc.) not chosen? Q: Why was character combination XYZ (":::",​ "​@"​ etc.) not chosen?
 +
 +A: There have been long and intensive public discussions over the choice of namespace separator in the past, and everyone at the internals meeting was familiar with the arguments against a wide range of potential characters. The possibilities were therefore very limited, as documented on the wiki page about this decision. [Link to Lukas' entry]
  
 Q: Why was "​\"​ chosen given that it makes it impossible to write something like "​spl_autoload_register(array("​myNamespace\theLoader",​ "​load"​));"​ because the \t would be interpreted as a tab? Q: Why was "​\"​ chosen given that it makes it impossible to write something like "​spl_autoload_register(array("​myNamespace\theLoader",​ "​load"​));"​ because the \t would be interpreted as a tab?
 +
 +A: It is already impossible to write Windows paths in PHP in the same way, ergo at least half the PHP community is already familiar with the idea that they need to either use single quotation marks or escape the backslash ("​\\"​).
  
 Q: Why do the PHP internals developer think that "​\"​ is not prone to cause issues when typos are made? Q: Why do the PHP internals developer think that "​\"​ is not prone to cause issues when typos are made?
Line 22: Line 30:
 Q: Don't the PHP internals developer think that the fact that "​\"​ is widely used as the escape character will be cause for confusion? Q: Don't the PHP internals developer think that the fact that "​\"​ is widely used as the escape character will be cause for confusion?
  
-Q: C++ uses "::"​ for namespaces, why did the PHP internals ​developer ​feel they needed to solve the ambiguity issues rather than leaving it to each developer to prevent ambiguity between namespace names and other identifiers?​+A: No, because the usage context is completely different. 
 + 
 +Q: C++ uses "::"​ for namespaces, why did the PHP internals ​developers ​feel they needed to solve the ambiguity issues rather than leaving it to each developer to prevent ambiguity between namespace names and other identifiers?​ 
 + 
 +A: Ambiguity is an edge case, meaning that developers wouldn'​t necessarily be aware of the potential for it through their own past experience, and debugging would be extremely difficult. Further, there was no way to provide a PHP error message on ambiguity without impacting performance in all cases. [Reference needed]
  
 Q: Why wasn't the proposal chosen to just require "use namespace"​ and "use class" chosen? Q: Why wasn't the proposal chosen to just require "use namespace"​ and "use class" chosen?
  
 Q: Do I have to prefix all my internal function names with \ now? Q: Do I have to prefix all my internal function names with \ now?
doc/scratchpad/namespacefaq.txt · Last modified: 2017/09/22 13:28 (external edit)