RE: [PHP-DEV] Simple Namespace Proposal
| From: | Dmitry Stogov | Date: | Fri, 06 Jul 2007 19:54:43 +0000 |
| Subject: | RE: [PHP-DEV] Simple Namespace Proposal | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-30565@lists.php.net to get a copy of this message | ||
PHP itself (without classes) hasn't compile-time constants (and variables).
You can define constants only in run-time using define(). This is the reason
why this proposal don't try to use constants and variables in namespaces. So
ithis approach is absolutely consistent.
BTW you can "import" not only namespace but also class from namespace.
<?php
namespace A::B;
class Foo {
const C = 5;
}
<?php
import A::B::Foo;
echo Foo::C;
I would like to start with this "simple" proposal and may be extend it with
constants and variables in the future.
Thanks. Dmitry.
> -----Original Message-----
> From: Stefan Walk [mailto:stefan.walk@gmail.com]
> Sent: Friday, July 06, 2007 10:26 PM
> To: Dmitry Stogov
> Cc: Brian Moon; internals@lists.php.net
> Subject: Re: [PHP-DEV] Simple Namespace Proposal
>
>
> On 04/07/07, Dmitry Stogov <dmitry@zend.com> wrote:
> > Nor variables naither constants.
> > They are defined in run-time.
>
> This seems to me like a bit of drawback. Would it be possible
> to add compile-time constants, then (like const FOO = 1;
> outside a class)? Creating a class inside a namespace for
> constants doesn't seem clean to me.
>
> Regards,
> Stefan
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>