librelist archives

« back to archive

The backslash is not useless at all

The backslash is not useless at all

From:
Loic d'Anterroches
Date:
2012-04-16 @ 18:50
Hello,

this is for William (Delkia) but can be of interest for others. The
first backslash \ in an use statement like this:

use \photon\config\Container as Conf;

is not useless. If you put:

use photon\config\Container as Conf;

in a namespace:

namespace photon\auth;

it will first try to resolve:

photon\auth\photon\config\Container

and without success, will try:

\photon\config\Container.

So, the difference is important. This is why I am reverting the commit
to avoid a lookup for nothing.

loïc

--
Indefero - Project management and code hosting - http://www.indefero.net
Photon - High Performance PHP Framework - http://photon-project.com
Céondo Ltd - Web + Science = Fun - http://www.ceondo.com




Re: [photon.users] The backslash is not useless at all

From:
William Martin
Date:
2012-04-16 @ 20:05
Thanks for the tips.

William


On Mon, Apr 16, 2012 at 8:50 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hello,
>
> this is for William (Delkia) but can be of interest for others. The
> first backslash \ in an use statement like this:
>
> use \photon\config\Container as Conf;
>
> is not useless. If you put:
>
> use photon\config\Container as Conf;
>
> in a namespace:
>
> namespace photon\auth;
>
> it will first try to resolve:
>
> photon\auth\photon\config\Container
>
> and without success, will try:
>
> \photon\config\Container.
>
> So, the difference is important. This is why I am reverting the commit
> to avoid a lookup for nothing.
>
> loïc
>
> --
> Indefero - Project management and code hosting - http://www.indefero.net
> Photon - High Performance PHP Framework - http://photon-project.com
> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com
>
>
>
>
>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] The backslash is not useless at all

From:
Loic d'Anterroches
Date:
2012-04-17 @ 06:27

On 2012-04-16 22:05, William MARTIN wrote:
> Thanks for the tips.

but effectively you define a namespace without the first backslash (\).
This can be used within a library where you can "move" a module from one
part of a tree to another. So, in some cases it totally makes sense. For
example, if you are in module foo\bar and want to use foo\bar\bong, you
could directly put a use bong;

loïc

> 
> On Mon, Apr 16, 2012 at 8:50 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
>> Hello,
>>
>> this is for William (Delkia) but can be of interest for others. The
>> first backslash \ in an use statement like this:
>>
>> use \photon\config\Container as Conf;
>>
>> is not useless. If you put:
>>
>> use photon\config\Container as Conf;
>>
>> in a namespace:
>>
>> namespace photon\auth;
>>
>> it will first try to resolve:
>>
>> photon\auth\photon\config\Container
>>
>> and without success, will try:
>>
>> \photon\config\Container.
>>
>> So, the difference is important. This is why I am reverting the commit
>> to avoid a lookup for nothing.
>>
>> loïc
>>
>> --
>> Indefero - Project management and code hosting - http://www.indefero.net
>> Photon - High Performance PHP Framework - http://photon-project.com
>> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com
>>
>>
>>
>>
>>
> 
> 
> 

-- 
Dr Loïc d'Anterroches
Founder Céondo Ltd

w: www.ceondo.com       |  e: loic@ceondo.com
t: +44 (0)207 183 0016  |  f: +44 (0)207 183 0124

Céondo Ltd
Dalton House
60 Windsor Avenue
London
SW19 2RR / United Kingdom