Hello,
PHP 5.3.0, released in June 2009, introduced namespacing, a feature we have never used yet since we were still supporting 5.2.
Jeroen submitted https://gerrit.wikimedia.org/r/14181 which use namespaces. Since that is, to my knowledge, the first patch that introduce namespace, I am opening this thread so we discuss about namespace introduction in MediaWiki.
PHP doc http://php.net/manual/en/language.namespaces.php
Thoughts?
On 05.07.2012, 12:01 Antoine wrote:
Hello,
PHP 5.3.0, released in June 2009, introduced namespacing, a feature we have never used yet since we were still supporting 5.2.
Jeroen submitted https://gerrit.wikimedia.org/r/14181 which use namespaces. Since that is, to my knowledge, the first patch that introduce namespace, I am opening this thread so we discuss about namespace introduction in MediaWiki.
Thoughts?
I think namespaces were discussed recently and we decided that we don't want to use them yet.
Max Semenik wrote:
On 05.07.2012, 12:01 Antoine wrote:
PHP 5.3.0, released in June 2009, introduced namespacing, a feature we have never used yet since we were still supporting 5.2.
Jeroen submitted https://gerrit.wikimedia.org/r/14181 which use namespaces. Since that is, to my knowledge, the first patch that introduce namespace, I am opening this thread so we discuss about namespace introduction in MediaWiki.
I think namespaces were discussed recently and we decided that we don't want to use them yet.
K. Peachey wrote:
Haven't we already discussed this like ten million times around?
I believe both of you are referring to (at least) this thread from May 2012 titled "Stance on PHP namespaces?" started by Jeroen De Dauw: http://lists.wikimedia.org/pipermail/wikitech-l/2012-May/thread.html#60651
Not sure why neither of you could come up with a mailing list cite, though I agree that re-hashing this discussion is silly. Someone should write a guideline on mediawiki.org, as Chad suggested in May.
MZMcBride
Le 05/07/12 10:58, MZMcBride a écrit :
believe both of you are referring to (at least) this thread from May 2012 titled "Stance on PHP namespaces?" started by Jeroen De Dauw: http://lists.wikimedia.org/pipermail/wikitech-l/2012-May/thread.html#60651
Oh thanks for finding that thread. Looks like we just talked about the poor choice of \ as a separator and hiphop.
The reason I opened this thread is so we give a GO/NOGO about using namespaces.
Hello,
On Thu, Jul 05, 2012 at 11:14:48AM +0200, Antoine Musso wrote:
The reason I opened this thread is so we give a GO/NOGO about using namespaces.
NOGO.
As it would be a pain for extensions to (at the same time/branch) support both: - older MWs without namespaces, and - newer MWs that would use namespaces.
Besides, PHP's namespace syntax is not remarkably smooth.
Kind regards, Christian
Hey,
As it would be a pain for extensions to (at the same time/branch) support both:
- older MWs without namespaces, and
- newer MWs that would use namespaces.
This is only an issue is we move existing classes from the top level namespace into something else. Using namespaces for new code does not cause hassle for extension developers at all. Furthermore you can alias class names since 5.3, so even if we where to move stuff, it could be done in such a way compat is kept.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
Hello Jeroen,
On Thu, Jul 05, 2012 at 12:48:50PM +0200, Jeroen De Dauw wrote:
As it would be a pain for extensions to (at the same time/branch) support both:
- older MWs without namespaces, and
- newer MWs that would use namespaces.
This is only an issue is we move existing classes from the top level namespace into something else.
But wouldn't just that be the natural thing to do, if we decide to adopt namespaces? I am probably missing something here, because ... isn't switching from “User” to “\User” pointless?
Using namespaces for new code does not cause hassle for extension developers at all.
That depends on what you mean by “hassle”. At least it leaves core in a inconsistent state. Some classes using namespaces, some not using them. If I were to write extensions for such a core code base (where whether or not one has to use a namespace is solely determined by the date of the source file), I'd at least be annoyed.
Furthermore you can alias class names since 5.3, so even if we where to move stuff, it could be done in such a way compat is kept.
Yes, of course you can. But as I said it has written pain all over it. You just move the migration pain from the extensions to core. Pain nonetheless.
Kind regards, Christian
Hey,
I am probably missing something here, because ... isn't switching from
“User” to “\User” pointless?
I am not suggesting doing this. What started this discussion is me having a class called Site in the namespace MW. So it's MW\Site rather then MWSite. (Unless you want to go with just Site and be fucked whenever some other package just dumping stuff in the top level NS happens to have such a class as well. Unlikely you say? I remember us having to rename some classes just for this reason (where PHP itself was the other package).)
At least it leaves core in a inconsistent state.
It's inconsistent now. Sure everything is in the top level NS, but we're using different prefix schemes at different places. We have classes prefixed with MW and we have those without this prefix. In this sense having a namespace is equivalent to a prefix. Introducing namespaces and migrating with full compat using aliases is a way to get rid of all the inconsistencies in the long run. Hmm... maybe I'm being naive here - not like "long term" arguments seem to have much weight when it comes to MW design.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Thu, Jul 5, 2012 at 5:14 AM, Antoine Musso hashar+wmf@free.fr wrote:
Le 05/07/12 10:58, MZMcBride a écrit :
believe both of you are referring to (at least) this thread from May 2012 titled "Stance on PHP namespaces?" started by Jeroen De Dauw: http://lists.wikimedia.org/pipermail/wikitech-l/2012-May/thread.html#60651
Oh thanks for finding that thread. Looks like we just talked about the poor choice of \ as a separator and hiphop.
The reason I opened this thread is so we give a GO/NOGO about using namespaces.
NOGO for core. My position hasn't changed in the past month and is unlikely to change in the near future.
-Chad
On 05.07.2012, 14:58 Chad wrote:
On Thu, Jul 5, 2012 at 5:14 AM, Antoine Musso hashar+wmf@free.fr wrote:
Le 05/07/12 10:58, MZMcBride a écrit :
believe both of you are referring to (at least) this thread from May 2012 titled "Stance on PHP namespaces?" started by Jeroen De Dauw: http://lists.wikimedia.org/pipermail/wikitech-l/2012-May/thread.html#60651
Oh thanks for finding that thread. Looks like we just talked about the poor choice of \ as a separator and hiphop.
The reason I opened this thread is so we give a GO/NOGO about using namespaces.
NOGO for core. My position hasn't changed in the past month and is unlikely to change in the near future.
+1.
Hey,
PHP 5.3.0, released in June 2009, introduced namespacing, a feature we have never used yet since we were still supporting 5.2.
MediaWiki 1.20 dropped support with 5.2 - there already is 5.3 code in core.
The reason I opened this thread is so we give a GO/NOGO about using
namespaces.
My opinion on this subject is that we probably should have guidelines on how to use and not use them, as we do with other language features. After having used namespaces myself at several places now, I see absolutely no reason to not allow developers that want to use them to use them in new code. I'd be good if the guidelines mentioned to not needlessly update existing code, especially if it breaks compatibility.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Thu, 05 Jul 2012 01:01:13 -0700, Antoine Musso hashar+wmf@free.fr wrote:
Hello,
PHP 5.3.0, released in June 2009, introduced namespacing, a feature we have never used yet since we were still supporting 5.2.
Jeroen submitted https://gerrit.wikimedia.org/r/14181 which use namespaces. Since that is, to my knowledge, the first patch that introduce namespace, I am opening this thread so we discuss about namespace introduction in MediaWiki.
PHP doc http://php.net/manual/en/language.namespaces.php
Thoughts?
I maintain that use of namespaces should be on a case-by-case basis. Only used if there's a significant advantage to using namespaces for some code. eg: A component with a huge pile of small classes for pieces of the component.
In this case, I don't see a good reason to use a generic MW namespace.
2012/7/5 Daniel Friesen lists@nadir-seen-fire.com:
On Thu, 05 Jul 2012 01:01:13 -0700, Antoine Musso hashar+wmf@free.fr wrote:
Hello,
PHP 5.3.0, released in June 2009, introduced namespacing, a feature we have never used yet since we were still supporting 5.2.
Jeroen submitted https://gerrit.wikimedia.org/r/14181 which use namespaces. Since that is, to my knowledge, the first patch that introduce namespace, I am opening this thread so we discuss about namespace introduction in MediaWiki.
PHP doc http://php.net/manual/en/language.namespaces.php
Thoughts?
I maintain that use of namespaces should be on a case-by-case basis. Only used if there's a significant advantage to using namespaces for some code. eg: A component with a huge pile of small classes for pieces of the component.
In this case, I don't see a good reason to use a generic MW namespace.
-- ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
By all means, GO for it at least in extensions. Namespaces are awesome there since they can spare you a lot of prefixing extension classes. Have not made my mind up about core though, there might be valid reasons why not to use them there.
wikitech-l@lists.wikimedia.org