Re: Reserved namespaces
| From: | Guilherme Blanco | Date: | Sat, 24 Jan 2009 14:38:13 +0000 |
| Subject: | Re: Reserved namespaces | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42813@lists.php.net to get a copy of this message | ||
IMHO, the prefix will turn everything more readable...
I already saw people experiencing some doubts regarding this piece of
code. I had to illustrate it everything.
namespace Foo;
class Bar
{
public function test()
{
try {
do_some_stuf();
} catch (Exception $e) { // Refers to Foo\Exception
// Special handling of Foo Exception
} catch (\Exception $e) { // Refers to PHP Exception
// Special handling of Exception
}
}
}
I just updated the code to explain wtf is happening... but he was just
trying to do a simple try { .. } catch (Exception $e) { ... } and
thought it was a bug since it was refering to Foo\Exception. Sounds
newbie, but you will have troubles in the future.
Regards,
On Fri, Jan 23, 2009 at 10:07 PM, Alain Williams <addw@phcomp.co.uk> wrote:
> On Fri, Jan 23, 2009 at 03:58:22PM -0800, Andrei Zmievski wrote:
>> Lukas Kahwe Smith wrote:
>> >I think the decision was to not yet bother with reserving namespaces or
>> >starting to namespace-ify extensions. We might however want to put out a
>> >naming guide for namespaces.
>>
>> I agree. Whether the error is raised or not on reserved namespaces can be
>> done later, but we should explicitly indicate that certain namespaces are
>> off-limits.
>
> Could take the simple convention that exists in perl with modules.
>
> Module names begin with a capital letter, pragmase are lower case, thus you have:
>
> use strict;
>
> use IO::File
>
> Nobody is made to do anything, however you loose the option to complain if your
> namespace starts with a lower case character.
>
> --
> Alain Williams
> Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
> +44 (0) 787 668 0256 http://www.phcomp.co.uk/
> Parliament Hill Computers Ltd. Registration Information:
> http://www.phcomp.co.uk/contact.php
> Past chairman of UKUUG: http://www.ukuug.org/
> #include <std_disclaimer.h>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9215-8480
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
São Paulo - SP/Brazil