Re: Simple Namespace Proposal
| From: | David Coallier | Date: | Fri, 06 Jul 2007 20:12:14 +0000 |
| Subject: | Re: Simple Namespace Proposal | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-30567@lists.php.net to get a copy of this message | ||
On 7/6/07, Dmitry Stogov <dmitry@zend.com> wrote:
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 {One thing I'm wondering (might have missed it on the list but we discussed that a little bit on irc..) Do we have to have a namespace per file or could we have our braces ? :) namespace A::B { class BooYa {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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
const C = 'Foo';} } --- Then.. import A::B::BooYa; echo BooYa::C; That way we can put more than one namespace within a file or such... just point me if I am replying to an existing question or re-asking :) Thanks, -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18