Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Stanislav Malyshev
import ::Exception AS WTF; import isn't the means to shuffle standard class names around. Import is the means to make names shorter. You already have one Exception in global space, you'd have to use other name for other class. -- Stanislav Malyshev, Zend Software Architect [EMAIL PROTECTED]

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Moritz Bechler
Hi internals, I think you are conentrating on the Exception (and even internal class) examples a bit too much. Take the following example: a.php: b.php: c.php: d.php: Running this example produces a "Fatal error: Import name 'Foo' conflicts with d

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Benjamin Schulz
The exception example is well an exception. Here you must inherit exception. That is simply how PHP works, it is an intended limitation. That said in this case you should not use Exception for your own stuff. Name it after your library or product, like MyProductException. Hey, i have an

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Benjamin Schulz
The above code works just fine. Yes there is a concept. import is best used within a namespace. So, namespace your code and there is no need to import global classes. Yep, it works if your whole application uses one namespace, but what if you have a core package that defines some except

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Marcus Boerger
Hello Benjamin, Wednesday, October 3, 2007, 5:33:21 PM, you wrote: >> >> if your exception is so general that it is called exception you can >> obviously simply use exception. > Maybe _my_ exception is a generic exception in _my_ framework and > implements some helper functions i need? The

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Benjamin Schulz
if your exception is so general that it is called exception you can obviously simply use exception. Maybe _my_ exception is a generic exception in _my_ framework and implements some helper functions i need? But the discussion is not about exceptions, it's about classnames that PHP declare

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Marcus Boerger
Hello Benjamin, if your exception is so general that it is called exception you can obviously simply use exception. If your exception is actually doing something than name that something. Meaning the name of the exception class is carrying information already. Thus every exception should be spec

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Marcus Boerger
Hello Stanislav, perfectly right :-) Tuesday, October 2, 2007, 10:21:20 PM, you wrote: >> But how to know in advance, e.g. think about other libraries, which >> public classes possibly exist? Isn't this problematic then? > That should be simple - if you write library using namespaces, no publ

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Gregory Beaver
Benjamin Schulz wrote: > On 02.10.2007, at 22:04, Stanislav Malyshev wrote: > > >>> >> import ::Exception as Notused; >>> import Foo::Exception; >>> ?> >>> >> >> I wouldn't actually recommend using such code. If you have >> Foo::Exception just use Foo::Exception - it's short enough :) >> > > And

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Benjamin Schulz
On 02.10.2007, at 22:04, Stanislav Malyshev wrote: I wouldn't actually recommend using such code. If you have Foo::Exception just use Foo::Exception - it's short enough :) And what if not? "throw App::package::subpackage::Exception" in a file that has the namespace "App::package::su

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-02 Thread Stanislav Malyshev
But how to know in advance, e.g. think about other libraries, which public classes possibly exist? Isn't this problematic then? That should be simple - if you write library using namespaces, no public classes would exist except for the internal ones :) By "public" I of course mean "belonging

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-02 Thread Stanislav Malyshev
But how to know in advance, e.g. think about other libraries, which public classes possibly exist? Isn't this problematic then? That should be simple - if you write library using namespaces, no public classes would exist except for the internal ones :) -- Stanislav Malyshev, Zend Software Arc

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-02 Thread Markus Fischer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, Greg Beaver wrote: > Benjamin Schulz wrote: >> Of course i want to refer to my own exception in my application or >> framework as "Exception", and of course i want to use it without >> prefixes (import myStuff::Exception AS MyStuffException), i wo

Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-02 Thread Stanislav Malyshev
I wouldn't actually recommend using such code. If you have Foo::Exception just use Foo::Exception - it's short enough :) -- Stanislav Malyshev, Zend Software Architect [EMAIL PROTECTED] http://www.zend.com/ (408)253-8829 MSN: [EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development

[PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-02 Thread Greg Beaver
Benjamin Schulz wrote: > Hi all, > > import Foo::Bar AS DomDocument; > import Foo::Exception; > import MyStuff::Dom::XsltProcessor; > > Result in a "Fatal error: Import name '...' conflicts with defined class" > Of course i want to refer to my own exception in my application or > framework as "Ex