Hello Internals,
we all were asked to stop discussing syntax of namespaces as we were told
that we would decide after the namespace functionality was fully implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway here goes
my take on it:
PHP is very close to Java and C++ in terms of Syntax. And many of our users
are familiar with one or even both of them. Also we have a tendency to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
-
namespace foo { }
-
package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current way of
nesting is very confusing:
namespace foo; namespace bar;
Best regards,
Marcus
Marcus Boerger wrote:
Hello Internals,
we all were asked to stop discussing syntax of namespaces as we were told
that we would decide after the namespace functionality was fully implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway here goes
my take on it:PHP is very close to Java and C++ in terms of Syntax. And many of our users
are familiar with one or even both of them. Also we have a tendency to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {} except
declare and other namespace declarations.
- package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current way of
nesting is very confusing:
namespace foo; namespace bar;
I prefer this syntax because it discourages multiple namespaces, but
still allows them (nesting is an inaccurate term in this case, I
strongly encourage not using it)
Greg
Em Sex, 2008-03-21 às 17:01 -0500, Gregory Beaver escreveu:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {} except
declare and other namespace declarations.
Indeed!
Here's my try:
http://felipe.ath.cx/diff/namespace.diff
http://felipe.ath.cx/diff/namespace.phpt
--
Regards,
Felipe Pena.
Hello Felipe,
looks pretty good to me. Let's see what other responses we get by late
wedensday.
marcus
Saturday, March 22, 2008, 12:46:08 PM, you wrote:
Em Sex, 2008-03-21 às 17:01 -0500, Gregory Beaver escreveu:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {} except
declare and other namespace declarations.
Indeed!
Here's my try:
http://felipe.ath.cx/diff/namespace.diff
http://felipe.ath.cx/diff/namespace.phpt
Best regards,
Marcus
Hi,
Am Samstag, den 22.03.2008, 16:29 +0100 schrieb Marcus Boerger:
[...]
looks pretty good to me. Let's see what other responses we get by late
wedensday.
I like the current syntax and don't think it is confusing. So -1 for
changing it.
cu, Lars
Lars Strojny wrote:
Hi,
Am Samstag, den 22.03.2008, 16:29 +0100 schrieb Marcus Boerger:
[...]looks pretty good to me. Let's see what other responses we get by late
wedensday.I like the current syntax and don't think it is confusing. So -1 for
changing it.cu, Lars
I'm also -1 on this one. If your namespace needs to be in brackets {}
then that means more indentation. Not that it's a huge deal but I like
to keep the indents to a minimum.
Hello Ryan,
Saturday, March 22, 2008, 6:50:36 PM, you wrote:
Lars Strojny wrote:
Hi,
Am Samstag, den 22.03.2008, 16:29 +0100 schrieb Marcus Boerger:
[...]looks pretty good to me. Let's see what other responses we get by late
wedensday.I like the current syntax and don't think it is confusing. So -1 for
changing it.cu, Lars
I'm also -1 on this one. If your namespace needs to be in brackets {}
then that means more indentation. Not that it's a huge deal but I like
to keep the indents to a minimum.
Who forces you to do indentation? Most C++ code that uses namespaces indeed
is not indented. And I see not reason it should. If it whould then the
namespaces with just a semicolon at the end would need the same indentation.
Best regards,
Marcus
Felipe Pena wrote:
Em Sex, 2008-03-21 às 17:01 -0500, Gregory Beaver escreveu:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {} except
declare and other namespace declarations.Indeed!
Here's my try:
http://felipe.ath.cx/diff/namespace.diff
http://felipe.ath.cx/diff/namespace.phpt
Hi Felipe,
The patch is pristine coding, but I do think the error message needs
some loving:
-
if (zend_do_namespace_check(TSRMLS_C) == FAILURE) {
-
zend_error(E_COMPILE_ERROR, "Only namespace declaration is allowed
in the script");
This implies that only "namespace" is allowed, and would be confusing to
99% of users. Might I suggest this error message instead:
"This script contains namespaces, all other code must be contained
within namespace declarations"
Greg
Em Sáb, 2008-03-22 às 17:19 -0500, Gregory Beaver escreveu:
Felipe Pena wrote:
Em Sex, 2008-03-21 às 17:01 -0500, Gregory Beaver escreveu:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {} except
declare and other namespace declarations.Indeed!
Here's my try:
http://felipe.ath.cx/diff/namespace.diff
http://felipe.ath.cx/diff/namespace.phptHi Felipe,
The patch is pristine coding, but I do think the error message needs
some loving:
if (zend_do_namespace_check(TSRMLS_C) == FAILURE) {
zend_error(E_COMPILE_ERROR, "Only namespace declaration is allowed
in the script");
This implies that only "namespace" is allowed, and would be confusing to
99% of users. Might I suggest this error message instead:"This script contains namespaces, all other code must be contained
within namespace declarations"
Nice. Patch updated! :)
--
Regards,
Felipe Pena.
In general I'd prefer one namespace per-file, at least as a best
practice and common advertised use. For this case it doesn't really
matter too much whether it's with or without brackets. My preference is
without because then you just stick it at the top and don't have an
extra level of indentation which you'd typically have with brackets.
For the not recommended case where you want to combine multiple files
with a tool I still prefer without brackets. The brackets again add
indentation and in addition, it's not really clear whether you can put
code in between namespaces definitions (between closing "}" and
"namespaces" keyword). You shouldn't be able to and without brackets
that becomes much more clear because current namespace is relevant until
the next namespace declaration; thus never allowing a "gap".
I think it's important for people to consider the former reasons as I
think without {} will lead be more intuitive and will lead to less
indentation.
I definitely prefer "namespace" as a keyword.
My 2 cents.
Andi
-----Original Message-----
From: Gregory Beaver [mailto:greg@chiaraquartet.net]
Sent: Friday, March 21, 2008 3:01 PM
To: Marcus Boerger
Cc: internals@lists.php.net
Subject: [PHP-DEV] Re: [RFC] Namespace syntax decisionMarcus Boerger wrote:
Hello Internals,
we all were asked to stop discussing syntax of namespaces as we
were told
that we would decide after the namespace functionality was fully
implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway
here
goes
my take on it:PHP is very close to Java and C++ in terms of Syntax. And many of
our
users
are familiar with one or even both of them. Also we have a tendency
to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {}
except
declare and other namespace declarations.
- package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current
way of
nesting is very confusing:
namespace foo; namespace bar;I prefer this syntax because it discourages multiple namespaces, but
still allows them (nesting is an inaccurate term in this case, I
strongly encourage not using it)Greg
Can't both (brackets and non) be supported? I have some sick people in
my own company that would LOVE if they could embed multiple namespaces
in the same file. In circles around my own cubicle, engineers prefer
to write one class per namespace, per file, as God intended. Various
Perl, Python & C influences have made some developers think
differently about code separation.
Can "namespace" exist as both a statement and a bracketed keyword?
Obviously, the documentation should encourage best practices, so
proper separation would be a primary topic... but accommodation for my
"alternative" engineers would also be available.
p
In general I'd prefer one namespace per-file, at least as a best
practice and common advertised use. For this case it doesn't really
matter too much whether it's with or without brackets. My preference
is
without because then you just stick it at the top and don't have an
extra level of indentation which you'd typically have with brackets.For the not recommended case where you want to combine multiple files
with a tool I still prefer without brackets. The brackets again add
indentation and in addition, it's not really clear whether you can put
code in between namespaces definitions (between closing "}" and
"namespaces" keyword). You shouldn't be able to and without brackets
that becomes much more clear because current namespace is relevant
until
the next namespace declaration; thus never allowing a "gap".I think it's important for people to consider the former reasons as I
think without {} will lead be more intuitive and will lead to less
indentation.I definitely prefer "namespace" as a keyword.
My 2 cents.
Andi-----Original Message-----
From: Gregory Beaver [mailto:greg@chiaraquartet.net]
Sent: Friday, March 21, 2008 3:01 PM
To: Marcus Boerger
Cc: internals@lists.php.net
Subject: [PHP-DEV] Re: [RFC] Namespace syntax decisionMarcus Boerger wrote:
Hello Internals,
we all were asked to stop discussing syntax of namespaces as we
were told
that we would decide after the namespace functionality was fully
implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway
here
goes
my take on it:PHP is very close to Java and C++ in terms of Syntax. And many of
our
users
are familiar with one or even both of them. Also we have a tendency
to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {}
except
declare and other namespace declarations.
- package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current
way of
nesting is very confusing:
namespace foo; namespace bar;I prefer this syntax because it discourages multiple namespaces, but
still allows them (nesting is an inaccurate term in this case, I
strongly encourage not using it)Greg
Can't both (brackets and non) be supported?
NO! This just creates confusion.
johannes
Hello Andi,
Wednesday, March 26, 2008, 7:12:18 AM, you wrote:
In general I'd prefer one namespace per-file, at least as a best
practice and common advertised use. For this case it doesn't really
matter too much whether it's with or without brackets. My preference is
without because then you just stick it at the top and don't have an
extra level of indentation which you'd typically have with brackets.
Since when do we enforce indentation anywher? And once again code I see all
around typically has no indentation for namespaces. What people sometimes
do is to indent if the have smaller stuff they explicitly import. But that
is a C++ specific thing.
For the not recommended case where you want to combine multiple files
with a tool I still prefer without brackets. The brackets again add
indentation and in addition, it's not really clear whether you can put
code in between namespaces definitions (between closing "}" and
"namespaces" keyword). You shouldn't be able to and without brackets
that becomes much more clear because current namespace is relevant until
the next namespace declaration; thus never allowing a "gap".
I think it's important for people to consider the former reasons as I
think without {} will lead be more intuitive and will lead to less
indentation.
Thanks for explaining your thoughts.
But I must be missing something completely here. Were do the indents come
from? And also I think quite the opposite is intuitive. Braces for
namespaces give you some control of where a namespace starts and where it
ends.
Last part is regarding the ability of multiple namespaces and no code
befaore, after or in between namespaces. Now first thing to recognize is
that having no braces for namespaces solves the issue of before, between
and after namespaces as there no longer is a between or after. But now it
is extremely unclear whether a namespace after a namespace is nesting or a
new namespace. Hence completely unintuitive. Especially since there is no
language out there that is in use and has anything like that. And even more
scary to me, you did not solve anything by this because people still could
write code prior to the namespace keyword. So no matter what we are screwed
and create a new version php scripts. Which I consider pretty bad. So
should we reconsider the limitation and have an anonymous namespace that
this code goes to? If not, how do we enforce this rule? How do we explain
that to users?
marcus
-----Original Message-----
From: Gregory Beaver [mailto:greg@chiaraquartet.net]
Sent: Friday, March 21, 2008 3:01 PM
To: Marcus Boerger
Cc: internals@lists.php.net
Subject: [PHP-DEV] Re: [RFC] Namespace syntax decisionMarcus Boerger wrote:
Hello Internals,
we all were asked to stop discussing syntax of namespaces as we
were told
that we would decide after the namespace functionality was fully
implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway
here
goes
my take on it:PHP is very close to Java and C++ in terms of Syntax. And many of
our
users
are familiar with one or even both of them. Also we have a tendency
to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
- namespace foo { }
This is acceptable if nothing can exist outside namespace foo {}
except
declare and other namespace declarations.
- package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current
way of
nesting is very confusing:
namespace foo; namespace bar;I prefer this syntax because it discourages multiple namespaces, but
still allows them (nesting is an inaccurate term in this case, I
strongly encourage not using it)Greg
--
Best regards,
Marcus
Marcus Boerger wrote:
language out there that is in use and has anything like that. And even more
scary to me, you did not solve anything by this because people still could
write code prior to the namespace keyword. So no matter what we are screwed
?
cellog@lot-49:~/workspace/php5$ cat test.php
<?php
$a = 'before namespace';
namespace oops;
cellog@lot-49:~/workspace/php5$ sapi/cli/php -n test.php
Fatal error: Namespace declaration statement has to be the very first
statement in the script in /home/cellog/workspace/php5/test.php on line 3
Greg
Hello Internals,
we all were asked to stop discussing syntax of namespaces as we were told
that we would decide after the namespace functionality was fully implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway here goes
my take on it:PHP is very close to Java and C++ in terms of Syntax. And many of our users
are familiar with one or even both of them. Also we have a tendency to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
- namespace foo { }
Since multiple namespaces are allowed in the same file we have no
choice but to use this syntax.
Otherwise, I would have gone for package foo;
-Hannes
Since multiple namespaces are allowed in the same file we have no
choice but to use this syntax.
Yes we have choice. Leave it as it is and stop raising this topic every
two weeks.
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Since multiple namespaces are allowed in the same file we have no
choice but to use this syntax.Yes we have choice. Leave it as it is and stop raising this topic every
two weeks.
My hero :)
- Steph
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Hello Stanislav,
Sunday, March 23, 2008, 2:51:30 AM, you wrote:
Since multiple namespaces are allowed in the same file we have no
choice but to use this syntax.
Yes we have choice. Leave it as it is and stop raising this topic every
two weeks.
Well the history simply is that many people did not agree. And you simply
cannot go head-trough-wall here. And committing and telling us down and
thinking you are someone special is not going to work. Quite some people
are unhappy with the current state, so either convince them with technical
arguments or change the current state.
Best regards,
Marcus
Well the history simply is that many people did not agree. And you simply
For any decision there would be many people that disagree. But we have
to end is somewhere and not rehash it endlessly.
are unhappy with the current state, so either convince them with technical
arguments or change the current state.
Myself and others explained reason for this decision many times, with
detailed technical arguments. I am unable to say something new on the
matter, unless some new questions are asked. I don't know what else I
can do to convince anybody who didn't listen to these arguments.
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Marcus Boerger wrote:
Hello Internals,
we all were asked to stop discussing syntax of namespaces as we were told
that we would decide after the namespace functionality was fully implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway here goes
my take on it:PHP is very close to Java and C++ in terms of Syntax. And many of our users
are familiar with one or even both of them. Also we have a tendency to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
namespace foo { }
package foo;
I did not notice until now that you had changed the keyword to package.
-1 on this change. Either namespace blah; or namespace blah {}.
Greg
Why can't we stick to consistency ? PHP (classes, functions,
interfaces, abstracts, etc) are all done the same way. What is the
"need" of changing this ?
I see reasons like :
- I don't like indentatation (Answer to that: PHP must make you quite
sad then... and I can't imagine what python makes you feel like...)
So I think what we should do here is either reassemble the ideas (That
were of course lost since the initial discussions).
- Why did we want to call it a package ? Simply because it behaves
exactly like packages ? - Why do we decide to have a whole new way of declaring namespaces ?
(IE: No braces) - Since we decided to have "namespaces" what is "so" bad about having
nested namespaces?
Do we want to be "that" different from others? I think having a
solution that looks a lot like other software languages is something
that will not only bring us users but also bring us a lot of love from
other language developers (when they have to use PHP (because yes,
some have to use other languages)).
Greg came up with a pretty good patch for multiple namespaces per
file. However it does not follow the "PHP Coding Practices" - In terms
of style and characters used.
Greg? Stas? Dmitry? Could we get a "resume" of the backstage talks you
guys spoke about? I'm sure you did so just a little taste to inform us
all of "why" we decided to change PHP's general syntax would be
awesome :)
Thanks,
D
Hi!
Why can't we stick to consistency ? PHP (classes, functions,
I think "consistency" became, as many other previously useful words, to
mean "agree with me" on this list, so it's meaningless.
Greg? Stas? Dmitry? Could we get a "resume" of the backstage talks you
guys spoke about? I'm sure you did so just a little taste to inform us
all of "why" we decided to change PHP's general syntax would be
awesome :)
We discussed this topic like 20 times already, so how you expect to hear
something new now?
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Hi,
PHP is very close to Java and C++ in terms of Syntax. And many of our users
are familiar with one or even both of them. Also we have a tendency to
especially take syntax from those two or be in line with those two
languages. That said I see two ways:
namespace foo { }
package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current way of
nesting is very confusing:
namespace foo; namespace bar;
I said in some previous post I won't like multiple namespaces per file
using the 2nd syntax. So imo: either on ns per file and the 2nd syntax
or allow multiple and use brackets. And then I prefer the latter.
johannes
Hi,
we all were asked to stop discussing syntax of namespaces as we were told
that we would decide after the namespace functionality was fully implemented.
Now I think that the functionallity is pretty much settled we should
revisit the syntax. We all have been very patient so far. Anyway here goes
my take on it:
Allowing multiple namespaces per file using the "namespace foo;" syntax
feels really bad for me. Therefore I basically agree with Marcus on the
two options.
namespace foo { }
package foo;
I favor 1) if we allow namespace nesting and 2) if not. The current
way of
nesting is very confusing:
namespace foo; namespace bar;
About the options I don't have strong opinions but I see that people
want multiple namespaces per file. We aren't like other languages which
enforce one class per file and I don't think we should enforce one
namespace per file. Therefore I prefer 1).
johannes