Re: How bad would it be to say/enforce that namespacing can only apply to classes and not normal functions?
| From: | Richard Quadling | Date: | Thu, 26 Jun 2008 10:41:27 +0000 |
| Subject: | Re: How bad would it be to say/enforce that namespacing can only apply to classes and not normal functions? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38636@lists.php.net to get a copy of this message | ||
2008/6/26 Hartmut Holzgraefe <hartmut@mysql.com>:
> Richard Quadling wrote:
>
> How bad would it be to say that namespacing can only apply to classes and
>> not normal functions?
>>
>
> i don't see namespacing as an OO only feature, IMHO it is a perfectly
> valid and useful thing for pure procedural code, too
>
> not having namespacing for procedural functions would leave
> the old ugly concept of bundling functions as static methods within
> dummy wrapper classes as only option for procedural name space
> emulation ... which AFAIR was one of the things we wanted to get
> rid of way back when the whole namespace idea first materialized?
>
>
Ok. I see your point and the idea of grouping related functionality into a
dummy class full of statics does feel wrong when there is no other benefit,
but from a userland code's perspective
namespace::function()
looks JUST like
ugly_bundled_class::static()
Internally, sure, they are completely different, but from a users
perspective, they are the same thing. Same amount of typing. Same syntax.
Nothing to differentiate.
So the issue to namespace::function() vs class::static() remains.
As I see it either precedence is the answer (user namespaces first, internal
namespaces next and global namespace being last) or a different symbol for
namespace.
Maybe namespace:::function() vs class::static().
Would that be enough?
Richard.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"