# Inconsistencies in 5.3

- Thread: https://externals.io/message/39568
- Original archive: https://news-web.php.net/php.internals/39568
- Started by Marcus Boerger on 2008-08-03T12:26:59+00:00
- Messages: 110
- Page 1 of 5: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/39568.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #39568 — Marcus Boerger — 2008-08-03T12:26:59+00:00

URL: https://externals.io/message/39568#39568

Hello Internals,

  please let's not introduce new inconsistencies. Rather lets make new
stuff consistent with old stuff during the alpha phase of 5.3.

1) new keyword 'use'. Semantically it is the same as 'static' or 'global'
so it should be used in the same location.

2) namespaces, either use 'package' and only one per file, or use
'namespace' with curly braces. Read this as be consistent with other
languages and even if one or two people do not like it the two main
languages out there which have it are Java which goes with the former and
C++ which does the latter. Please chose and not mix it. Also our mix is a
nightmare when developing code.

If we feel we have to keep the keyword 'namesapce' but cannot have curly
braces, than I suggest we disallow multiple namespace per file.

And there is no technical reason and surely no other reason whatsoever to
not have curly braces. If there is then we either fix that or went with the
wrong approach.

3) __invokable, see Etiene's mail

Best regards,
 Marcus

---

## #39571 — Jeremy Privett — 2008-08-03T15:25:51+00:00

URL: https://externals.io/message/39568#39571

Hey Marcus,



> Hello Internals,
>
>   please let's not introduce new inconsistencies. Rather lets make new
> stuff consistent with old stuff during the alpha phase of 5.3.
>
> 1) new keyword 'use'. Semantically it is the same as 'static' or 'global'
> so it should be used in the same location.
>
> 2) namespaces, either use 'package' and only one per file, or use
> 'namespace' with curly braces. Read this as be consistent with other
> languages and even if one or two people do not like it the two main
> languages out there which have it are Java which goes with the former and
> C++ which does the latter. Please chose and not mix it. Also our mix is a
> nightmare when developing code.
>
> If we feel we have to keep the keyword 'namesapce' but cannot have curly
> braces, than I suggest we disallow multiple namespace per file.
>
> And there is no technical reason and surely no other reason whatsoever to
> not have curly braces. If there is then we either fix that or went with  
> the
> wrong approach.
>
> 3) __invokable, see Etiene's mail
>
> Best regards,
>  Marcus
>
>

I'm +1 with you on all of these. Unfortunately, #2 has been beat to death,
revived, and beat to death again so many times that the chances of getting
anyone to budge on it now are probably pretty slim. It is inconsistent to
not allow curly braces on "namespace" when *every other similar construct
in the language* uses curly braces (this is like str_* vs str* all over
again, haven't we learned by now?).

Thanks.

-- 
Jeremy Privett
Chief Software Architect
Omega Vortex Corporation

http://www.omegavortex.net

---

## #39589 — Moriyoshi Koizumi — 2008-08-04T00:48:55+00:00

URL: https://externals.io/message/39568#39589 · In reply to: #39568

Fully agreed with all of those. (especially for 1)

Moriyoshi

Marcus Boerger wrote:
> Hello Internals,
> 
>   please let's not introduce new inconsistencies. Rather lets make new
> stuff consistent with old stuff during the alpha phase of 5.3.
> 
> 1) new keyword 'use'. Semantically it is the same as 'static' or 'global'
> so it should be used in the same location.
> 
> 2) namespaces, either use 'package' and only one per file, or use
> 'namespace' with curly braces. Read this as be consistent with other
> languages and even if one or two people do not like it the two main
> languages out there which have it are Java which goes with the former and
> C++ which does the latter. Please chose and not mix it. Also our mix is a
> nightmare when developing code.
> 
> If we feel we have to keep the keyword 'namesapce' but cannot have curly
> braces, than I suggest we disallow multiple namespace per file.
> 
> And there is no technical reason and surely no other reason whatsoever to
> not have curly braces. If there is then we either fix that or went with the
> wrong approach.
> 
> 3) __invokable, see Etiene's mail
> 
> Best regards,
>  Marcus
> 
> 


-- 
Moriyoshi Koizumi <moriyoshi@at.wakwak.com

---

## #39593 — Stanislav Malyshev — 2008-08-04T04:53:15+00:00

URL: https://externals.io/message/39568#39593 · In reply to: #39568

Hi!

> 1) new keyword 'use'. Semantically it is the same as 'static' or 'global'
> so it should be used in the same location.

Of course it's not. It does entirely different thing from static or 
global, it doesn't even deal with variables.

> 2) namespaces, either use 'package' and only one per file, or use
> 'namespace' with curly braces. Read this as be consistent with other
> languages and even if one or two people do not like it the two main

I don't see any requirement for PHP to mimic other languages up to 
minute detail of keyword and separator usage.

> And there is no technical reason and surely no other reason whatsoever to
> not have curly braces. If there is then we either fix that or went with the
> wrong approach.

There are reason, and they were amply explained in past 10 revolutions 
of this topic.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #39596 — Stanislav Malyshev — 2008-08-04T05:09:57+00:00

URL: https://externals.io/message/39568#39596 · In reply to: #39593

Hi!

> Of course it's not. It does entirely different thing from static or 
> global, it doesn't even deal with variables.

Or you meant "use" in lambda definition? Then I don't have opinion to 
either side :)
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #39597 — Dmitry Stogov — 2008-08-04T06:55:00+00:00

URL: https://externals.io/message/39568#39597 · In reply to: #39568

Hi Marcus,

see below

Marcus Boerger wrote:
> Hello Internals,
> 
>   please let's not introduce new inconsistencies. Rather lets make new
> stuff consistent with old stuff during the alpha phase of 5.3.
> 
> 1) new keyword 'use'. Semantically it is the same as 'static' or 'global'
> so it should be used in the same location.

For me 'use' is the best keyword as it says that closure uses variables 
from current content. (the same keyword is used for import from namespaces)

> 2) namespaces, either use 'package' and only one per file, or use
> 'namespace' with curly braces. Read this as be consistent with other
> languages and even if one or two people do not like it the two main
> languages out there which have it are Java which goes with the former and
> C++ which does the latter. Please chose and not mix it. Also our mix is a
> nightmare when developing code.
> 
> If we feel we have to keep the keyword 'namesapce' but cannot have curly
> braces, than I suggest we disallow multiple namespace per file.
> 
> And there is no technical reason and surely no other reason whatsoever to
> not have curly braces. If there is then we either fix that or went with the
> wrong approach.

I don't like multiple namespaces per file too.
As I remember they were introduced by Greg's request related to 
ext/phar. May be he already changed his mind.

'package' or 'namespace' is not so important for me.

Thanks. Dmitry.

> 3) __invokable, see Etiene's mail
> 
> Best regards,
>  Marcus

---

## #39601 — Hannes Magnusson — 2008-08-04T07:55:07+00:00

URL: https://externals.io/message/39568#39601 · In reply to: #39597

>
> I don't like multiple namespaces per file too.
> As I remember they were introduced by Greg's request related to ext/phar.
> May be he already changed his mind.
>

I don't think anyone but him likes multiple namespaces per file. I do
remember a PhD thesis sized mail from him explaining why multiple
namespaces per file was needed though (can hardly believe anyone read
the whole thing..).

-Hannes

---

## #39603 — Stefan Priebsch — 2008-08-04T08:28:35+00:00

URL: https://externals.io/message/39568#39603 · In reply to: #39601

Hannes Magnusson schrieb:
> I don't think anyone but him likes multiple namespaces per file. I do
> remember a PhD thesis sized mail from him explaining why multiple
> namespaces per file was needed though (can hardly believe anyone read
> the whole thing..).

In some deployment processes, multiple PHP files are merged together 
into one file. Symfony, for example, does this, at least optionally.

Regards,

Stefan

-- 
  >e-novative> - We make IT work for you.

  e-novative GmbH - HR: Amtsgericht München HRB 139407
  Sitz: Wolfratshausen - GF: Dipl. Inform. Stefan Priebsch

  http://www.e-novative.de - GnuPG Key: 0x7DB67F7F

---

## #39604 — Lukas Kahwe Smith — 2008-08-04T08:32:26+00:00

URL: https://externals.io/message/39568#39604 · In reply to: #39603

> Hannes Magnusson schrieb:
> > […]
>
> In some deployment processes, multiple PHP files are merged together  
> into one file. Symfony, for example, does this, at least optionally.


Right, this is common practice to reduce disk I/O without having to  
make development too hard. Also that way people can pick and choose  
what they want to include (like not all drivers of a DBAL).

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #39605 — Hannes Magnusson — 2008-08-04T08:36:59+00:00

URL: https://externals.io/message/39568#39605 · In reply to: #39604

>
> 
>
> > […]
>
>
> Right, this is common practice to reduce disk I/O without having to make
> development too hard. Also that way people can pick and choose what they
> want to include (like not all drivers of a DBAL).

Fair enough.
Then lets keep the name "namespace" and use curly braces.

-Hannes

---

## #39606 — Marcus Boerger — 2008-08-04T08:41:13+00:00

URL: https://externals.io/message/39568#39606 · In reply to: #39604

Hello Lukas,

Monday, August 4, 2008, 10:32:26 AM, you wrote:


> 

> > […]


> Right, this is common practice to reduce disk I/O without having to  
> make development too hard. Also that way people can pick and choose  
> what they want to include (like not all drivers of a DBAL).

If an edgecase optimization is th eonly reason then I am against this
even more.

Best regards,
 Marcus

---

## #39607 — Marcus Boerger — 2008-08-04T08:42:33+00:00

URL: https://externals.io/message/39568#39607 · In reply to: #39597

Hello Dmitry,

Monday, August 4, 2008, 8:55:00 AM, you wrote:

> Hi Marcus,

> see below

> Marcus Boerger wrote:
> > […]

> For me 'use' is the best keyword as it says that closure uses variables 
> from current content. (the same keyword is used for import from namespaces)

To be clear, I wasn't complaining about the keyword per se. I just prefer
it to be inside the curly braces of a closure next to global rather than in
front of it.

> > […]

> I don't like multiple namespaces per file too.
> As I remember they were introduced by Greg's request related to 
> ext/phar. May be he already changed his mind.

> 'package' or 'namespace' is not so important for me.

> Thanks. Dmitry.

> > […]




Best regards,
 Marcus

---

## #39608 — Lukas Kahwe Smith — 2008-08-04T08:49:43+00:00

URL: https://externals.io/message/39568#39608 · In reply to: #39606

> Hello Lukas,
>
> Monday, August 4, 2008, 10:32:26 AM, you wrote:
>
>
> > […]
>
> > […]
>
>
> > […]
>
> If an edgecase optimization is th eonly reason then I am against this
> even more.


its not an edge optimization .. like i said its "common practice" in  
many PHP frameworks. this way they can more easily develop the code,  
while not having to suffer the drawbacks from a lot of disk I/O from  
files that need to be loaded in every request anyways.

and those frameworks are the main users of namespaces, because they  
pull in libs from all sorts of libraries, add plugins etc.

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #39610 — Marcus Boerger — 2008-08-04T08:58:16+00:00

URL: https://externals.io/message/39568#39610 · In reply to: #39608

Hello Lukas,

Monday, August 4, 2008, 10:49:43 AM, you wrote:


> 

> > […]


> its not an edge optimization .. like i said its "common practice" in  
> many PHP frameworks. this way they can more easily develop the code,  
> while not having to suffer the drawbacks from a lot of disk I/O from  
> files that need to be loaded in every request anyways.

> and those frameworks are the main users of namespaces, because they  
> pull in libs from all sorts of libraries, add plugins etc.

In that case lets have curly braces at least to be consistent with the rest
of the language as every other grouping statement has curly braces.

Best regards,
 Marcus

---

## #39613 — Andrey Hristov — 2008-08-04T09:42:17+00:00

URL: https://externals.io/message/39568#39613 · In reply to: #39608

Hi,
Lukas Kahwe Smith wrote:
> 
> 
> 
> > […]
> 
> 
> its not an edge optimization .. like i said its "common practice" in 
> many PHP frameworks. this way they can more easily develop the code, 
> while not having to suffer the drawbacks from a lot of disk I/O from 
> files that need to be loaded in every request anyways.

isn't that easily solved by using a opcode cache?

> and those frameworks are the main users of namespaces, because they pull 
> in libs from all sorts of libraries, add plugins etc.
> 

Andrey

---

## #39614 — Lukas Kahwe Smith — 2008-08-04T09:48:08+00:00

URL: https://externals.io/message/39568#39614 · In reply to: #39613

> Hi,
> Lukas Kahwe Smith wrote:
> > […]
>
> isn't that easily solved by using a opcode cache?


The op code cache can reduce the overhead, but not all. Obviously  
there still needs to be work done to determine if the file has  
changed. of course you can just tell APC to never do that, but i think  
this is a setting very few people consider and its definitely not made  
for general purpose frameworks, that want to be easy to use while  
still being as fast as possible.

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #39615 — Markus Fischer — 2008-08-04T09:56:29+00:00

URL: https://externals.io/message/39568#39615 · In reply to: #39613

Hi,

Andrey Hristov wrote:
> isn't that easily solved by using a opcode cache?

I think this is also one of the things you won't have often at hosters.

I guess there's a speedup by having one file and no cache available, 
which is the argument here. Question is: where does that leave us :) If 
I remember correctly in the past it has been appealed to whether the 
one-file is really a benefit in practice. Who knows and who can tell?

cheers,
- Markus

---

## #39617 — david.zuelke@bitextender.com — 2008-08-04T10:19:42+00:00

URL: https://externals.io/message/39568#39617 · In reply to: #39610

Am 04.08.2008 um 10:58 schrieb Marcus Boerger:

> Hello Lukas,
>
> Monday, August 4, 2008, 10:49:43 AM, you wrote:
>
> > […]
>
> > […]
>
> In that case lets have curly braces at least to be consistent with  
> the rest
> of the language as every other grouping statement has curly braces.


+1


David

---

## #39618 — david.zuelke@bitextender.com — 2008-08-04T10:20:11+00:00

URL: https://externals.io/message/39568#39618 · In reply to: #39607

Am 04.08.2008 um 10:42 schrieb Marcus Boerger:

> Hello Dmitry,
>
> Monday, August 4, 2008, 8:55:00 AM, you wrote:
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> To be clear, I wasn't complaining about the keyword per se. I just  
> prefer
> it to be inside the curly braces of a closure next to global rather  
> than in
> front of it.

I think that's quite a logical and consistent argument.

+1


David

---

## #39619 — Derick Rethans — 2008-08-04T10:38:08+00:00

URL: https://externals.io/message/39568#39619 · In reply to: #39607

> Monday, August 4, 2008, 8:55:00 AM, you wrote:
> 
> > […]
> 
> > […]
> 
> To be clear, I wasn't complaining about the keyword per se. I just 
> prefer it to be inside the curly braces of a closure next to global 
> rather than in front of it.

I'd have to agree with that... the place where it is used now is kinda 
strange.

regards,
Derick

-- 
HEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org

---

## #39627 — Dmitry Stogov — 2008-08-04T11:38:36+00:00

URL: https://externals.io/message/39568#39627 · In reply to: #39607

Marcus Boerger wrote:
> Hello Dmitry,
> 
> Monday, August 4, 2008, 8:55:00 AM, you wrote:
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]
> 
> To be clear, I wasn't complaining about the keyword per se. I just prefer
> it to be inside the curly braces of a closure next to global rather than in
> front of it.
> 

No. The list of lexical variables is a part of the closure definition.

The earlier implementation had "lexical" keyword which worked as you are 
suggesting, but it was much unclear.

Thanks. Dmitry.

---

## #39632 — Andi Gutmans — 2008-08-04T15:29:33+00:00

URL: https://externals.io/message/39568#39632 · In reply to: #39603

> -----Original Message-----
> From: Stefan Priebsch [mailto:stefan.priebsch@e-novative.de]
> Sent: Monday, August 04, 2008 1:29 AM
> To: Hannes Magnusson
> Cc: Dmitry Stogov; Marcus Boerger; internals@lists.php.net
> Subject: Re: [PHP-DEV] Inconsistencies in 5.3
> 
> Hannes Magnusson schrieb:
> > […]
> 
> In some deployment processes, multiple PHP files are merged together
> into one file. Symfony, for example, does this, at least optionally.

We were not big fans of this but were convinced that for these frameworks it'd be reasonable. We agreed that we would make sure people understand that using multiple namespaces per-file is not a best practice and is discouraged from non-generated code.

Re: braces, I don't think it's a big deal but I would prefer without braces. Given that I think people should only have one namespace per file, the braces is a PITA because it already starts you off in an additional layer of indentation. We all know that whitespace does matter :)
Also another reason to not have braces because then it then makes sure that you don't go back into a global namespace and it is truly only used in these framework concatenation use cases.

Btw, I am both a C++ and Java developer and it honestly doesn't confuse me either way. I do prefer the "namespace" keyword because for me personally it better reflects what we have here. I always associate package with something that maps more directly to files but again, this could just be my own bias and I am sure I would get used to either very quickly. In general, people will always have pre conceived notions re: names but I have learnt that once a name is picked people will get used to them very quickly. This is true for most naming in life incl. personal life :)

Andi

---

## #39641 — Greg Beaver — 2008-08-04T20:40:53+00:00

URL: https://externals.io/message/39568#39641 · In reply to: #39597

Dmitry Stogov wrote:
> I don't like multiple namespaces per file too.
> As I remember they were introduced by Greg's request related to 
> ext/phar. May be he already changed his mind.
> 
> 'package' or 'namespace' is not so important for me.

To be correct, this has nothing to do with ext/phar, but everything to 
do with how PHP users do things now.  There are several apps such as 
Doctrine that allow "compiling" their whole libraries into a single 
large file.  This results in substantial performance improvement 
depending on app design both with and without opcode cache, verified 
independently by me and by Stas in Zend's labs.

I personally probably won't be using multiple namespaces per file except 
in rare cases, but I see plenty of good reasons to allow it.

Regards,
Greg

---

## #39643 — Greg Beaver — 2008-08-04T20:45:00+00:00

URL: https://externals.io/message/39568#39643 · In reply to: #39605

Hannes Magnusson wrote:
> 
> > […]
> 
> Fair enough.
> Then lets keep the name "namespace" and use curly braces.

I said it before, and I'll say it again, I am fine with this approach, 
especially with Dmitry's (old) proposed syntax allowing namespace-less 
code within namespace {}:

<?php
namespace foo {
class blah{}
}
namespace {
// put legacy code here
$a = new blah;
}
?>

Greg

---

## #39644 — Marcus Boerger — 2008-08-04T20:52:21+00:00

URL: https://externals.io/message/39568#39644 · In reply to: #39632

Hello Andi,

Monday, August 4, 2008, 5:29:33 PM, you wrote:

> > […]

> We were not big fans of this but were convinced that for these
> frameworks it'd be reasonable. We agreed that we would make sure people
> understand that using multiple namespaces per-file is not a best practice
> and is discouraged from non-generated code.

> Re: braces, I don't think it's a big deal but I would prefer without
> braces. Given that I think people should only have one namespace per
> file, the braces is a PITA because it already starts you off in an
> additional layer of indentation. We all know that whitespace does matter :)

I fail to see a connection here and any decent editor that does
auto-indentation can be configured to not do so for select structures and
usually people do so for namespaces.

> Also another reason to not have braces because then it then makes sure
> that you don't go back into a global namespace and it is truly only used
> in these framework concatenation use cases.

This can easily be addressed in the parser.

> Btw, I am both a C++ and Java developer and it honestly doesn't confuse
> me either way. I do prefer the "namespace" keyword because for me
> personally it better reflects what we have here. I always associate
> package with something that maps more directly to files but again, this
> could just be my own bias and I am sure I would get used to either very
> quickly. In general, people will always have pre conceived notions re:
> names but I have learnt that once a name is picked people will get used
> to them very quickly. This is true for most naming in life incl. personal life :)

> Andi



Best regards,
 Marcus

---

Next page: https://externals.io/message/39568.md?page=2
