Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Stance on PHP namespaces?

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


jeroendedauw at gmail

May 16, 2012, 3:36 PM

Post #1 of 15 (219 views)
Permalink
Stance on PHP namespaces?

Hey,

I am not aware of any guidelines regarding the usage of PHP namespaces in
MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20
is the first release in which we can actually use it. So I'm curious on
peoples thoughts on how to use this new features, if at all, in core and in
extensions. As far as I get it, we cannot simply put it into core without
breaking compat all over he place, but could gradually introduce it for new
components. For new extensions it's a lot easier of course, which happens
to be the use case I'm currently facing, and wondering what to best do.
MediaWiki\ExtensionName seems like a reasonable NS for extension classes.

Cheers

--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil.
--
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


maxsem.wiki at gmail

May 16, 2012, 3:52 PM

Post #2 of 15 (216 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On 17.05.2012, 2:36 Jeroen wrote:

> Hey,

> I am not aware of any guidelines regarding the usage of PHP namespaces in
> MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20
> is the first release in which we can actually use it. So I'm curious on
> peoples thoughts on how to use this new features, if at all, in core and in
> extensions. As far as I get it, we cannot simply put it into core without
> breaking compat all over he place, but could gradually introduce it for new
> components. For new extensions it's a lot easier of course, which happens
> to be the use case I'm currently facing, and wondering what to best do.
> MediaWiki\ExtensionName seems like a reasonable NS for extension classes.

Frankly, the namespace syntax in PHP is so atrocitous that I would
like to never see namespaces in out code:P Seriously though, I think
we should start slowly, maybe not including namespaces in 1.20 and
then tread carefully - some extension devs might want to be compatible
with older MW versions that support PHP 5.2.

--
Best regards,
Max Semenik ([[User:MaxSem]])


_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


lists at nadir-seen-fire

May 16, 2012, 4:03 PM

Post #3 of 15 (219 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On Wed, 16 May 2012 15:52:44 -0700, Max Semenik <maxsem.wiki [at] gmail>
wrote:

> On 17.05.2012, 2:36 Jeroen wrote:
>
>> Hey,
>
>> I am not aware of any guidelines regarding the usage of PHP namespaces
>> in
>> MediaWiki and di not find any on MediaWiki.org. Not surprising since
>> 1.20
>> is the first release in which we can actually use it. So I'm curious on
>> peoples thoughts on how to use this new features, if at all, in core
>> and in
>> extensions. As far as I get it, we cannot simply put it into core
>> without
>> breaking compat all over he place, but could gradually introduce it for
>> new
>> components. For new extensions it's a lot easier of course, which
>> happens
>> to be the use case I'm currently facing, and wondering what to best do.
>> MediaWiki\ExtensionName seems like a reasonable NS for extension
>> classes.
>
> Frankly, the namespace syntax in PHP is so atrocitous that I would
> like to never see namespaces in out code:P Seriously though, I think
> we should start slowly, maybe not including namespaces in 1.20 and
> then tread carefully - some extension devs might want to be compatible
> with older MW versions that support PHP 5.2.
>

I don't think we should use namespaces at all unless there is a good
reason for it.

The only case I think we should allow namespaces in is within a MediaWiki
component with a lot of small classes related to the component.

--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


preilly at wikimedia

May 16, 2012, 4:10 PM

Post #4 of 15 (218 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On Wed, May 16, 2012 at 4:03 PM, Daniel Friesen
<lists [at] nadir-seen-fire>wrote:

> On Wed, 16 May 2012 15:52:44 -0700, Max Semenik <maxsem.wiki [at] gmail>
> wrote:
>
> On 17.05.2012, 2:36 Jeroen wrote:
>>
>> Hey,
>>>
>>
>> I am not aware of any guidelines regarding the usage of PHP namespaces in
>>> MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20
>>> is the first release in which we can actually use it. So I'm curious on
>>> peoples thoughts on how to use this new features, if at all, in core and
>>> in
>>> extensions. As far as I get it, we cannot simply put it into core without
>>> breaking compat all over he place, but could gradually introduce it for
>>> new
>>> components. For new extensions it's a lot easier of course, which happens
>>> to be the use case I'm currently facing, and wondering what to best do.
>>> MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
>>>
>>
>> Frankly, the namespace syntax in PHP is so atrocitous that I would
>> like to never see namespaces in out code:P Seriously though, I think
>> we should start slowly, maybe not including namespaces in 1.20 and
>> then tread carefully - some extension devs might want to be compatible
>> with older MW versions that support PHP 5.2.
>>
>>
> I don't think we should use namespaces at all unless there is a good
> reason for it.
>
> The only case I think we should allow namespaces in is within a MediaWiki
> component with a lot of small classes related to the component.


Well namespaces can provide for better organization, readability and
dependency tracking among other things. So, it's probably worth
investigating this a bit more.


>
>
> --
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>
>
> ______________________________**_________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/**mailman/listinfo/wikitech-l<https://lists.wikimedia.org/mailman/listinfo/wikitech-l>
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


tchay at wikimedia

May 16, 2012, 4:48 PM

Post #5 of 15 (219 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On May 16, 2012, at 3:52 PM, Max Semenik wrote:

> Frankly, the namespace syntax in PHP is so atrocitous that I would
> like to never see namespaces in out code:P


Ahh the namespace separator!

https://wiki.php.net/rfc/namespaceseparator

Brings back memories.

Hmm, Now that you mention it maybe we should have used ":P" as the namespace separator. ;-)

( I miss ":)" That would have made PHP a much happier place. It already has a lot of money ($), now it just needs some smileys.)
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


tparscal at wikimedia

May 16, 2012, 5:43 PM

Post #6 of 15 (217 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

The namespace separator might be ugly, but it's in good company with the
rest of the syntax of PHP.

- Trevor

On Wed, May 16, 2012 at 4:48 PM, Terry Chay <tchay [at] wikimedia> wrote:

>
> On May 16, 2012, at 3:52 PM, Max Semenik wrote:
>
> > Frankly, the namespace syntax in PHP is so atrocitous that I would
> > like to never see namespaces in out code:P
>
>
> Ahh the namespace separator!
>
> https://wiki.php.net/rfc/namespaceseparator
>
> Brings back memories.
>
> Hmm, Now that you mention it maybe we should have used ":P" as the
> namespace separator. ;-)
>
> ( I miss ":)" That would have made PHP a much happier place. It already
> has a lot of money ($), now it just needs some smileys.)
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


innocentkiller at gmail

May 16, 2012, 6:01 PM

Post #7 of 15 (217 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On Wed, May 16, 2012 at 6:52 PM, Max Semenik <maxsem.wiki [at] gmail> wrote:
> Frankly, the namespace syntax in PHP is so atrocitous that I would
> like to never see namespaces in out code:P Seriously though, I think
> we should start slowly, maybe not including namespaces in 1.20 and
> then tread carefully - some extension devs might want to be compatible
> with older MW versions that support PHP 5.2.
>

I agree. I think the syntax was completely batshit, and it makes me cringe
whenever I see it. Don't expect me to use them ;-)

That being said, I don't see any real harm in writing up some guidelines if
extensions want to use them--but please let's tread carefully here. Shiny
new features are not always better features.

-Chad

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


questpc at rambler

May 16, 2012, 11:06 PM

Post #8 of 15 (211 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

Dmitriy Sintsov.

Actually dollar sign as variable name prefix comes from Perl, which was very
popular language during PHP3 / PHP4 time. The authors of PHP probably wanted to
simplify Perl to PHP porting.

17 Май 2012 г. 3:48:55 пользователь Terry Chay (tchay [at] wikimedia) написал



On May 16, 2012, at 3:52 PM, Max Semenik wrote:

> Frankly, the namespace syntax in PHP is so atrocitous that I would
> like to never see namespaces in out code:P


Ahh the namespace separator!

https://wiki.php.net/rfc/namespaceseparator

Brings back memories.

Hmm, Now that you mention it maybe we should have used ":P" as the namespace
separator. ;-)

( I miss ":)" That would have made PHP a much happier place. It already has a
lot of money ($), now it just needs some smileys.)

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


niklas.laxstrom at gmail

May 17, 2012, 3:13 AM

Post #9 of 15 (205 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On 17 May 2012 01:36, Jeroen De Dauw <jeroendedauw [at] gmail> wrote:
> Hey,
>
> I am not aware of any guidelines regarding the usage of PHP namespaces in
> MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20
> is the first release in which we can actually use it. So I'm curious on
> peoples thoughts on how to use this new features, if at all, in core and in
> extensions. As far as I get it, we cannot simply put it into core without
> breaking compat all over he place, but could gradually introduce it for new
> components. For new extensions it's a lot easier of course, which happens
> to be the use case I'm currently facing, and wondering what to best do.
> MediaWiki\ExtensionName seems like a reasonable NS for extension classes.

I just came across to a reference to PSR-0 while researching another
unrelated thing.
Little bit of googling gives this: https://gist.github.com/1234504

Seems to be somewhat relevant to this discussion, although pretty much
incompatible with what we do in MediaWiki currently.
-Niklas

--
Niklas Laxström

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Platonides at gmail

May 17, 2012, 9:59 AM

Post #10 of 15 (209 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

Wouldn't that make it incompatible with hiphop?



_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


tchay at wikimedia

May 17, 2012, 10:00 AM

Post #11 of 15 (205 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

We probably should consider prefixing TLD classes (like SPL Iterators and such) with a \ just to be compatible with namespacing down the road.


On May 17, 2012, at 3:13 AM, Niklas Laxstrm wrote:

> On 17 May 2012 01:36, Jeroen De Dauw <jeroendedauw [at] gmail> wrote:
>> Hey,
>>
>> I am not aware of any guidelines regarding the usage of PHP namespaces in
>> MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20
>> is the first release in which we can actually use it. So I'm curious on
>> peoples thoughts on how to use this new features, if at all, in core and in
>> extensions. As far as I get it, we cannot simply put it into core without
>> breaking compat all over he place, but could gradually introduce it for new
>> components. For new extensions it's a lot easier of course, which happens
>> to be the use case I'm currently facing, and wondering what to best do.
>> MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
>
> I just came across to a reference to PSR-0 while researching another
> unrelated thing.
> Little bit of googling gives this: https://gist.github.com/1234504
>
> Seems to be somewhat relevant to this discussion, although pretty much
> incompatible with what we do in MediaWiki currently.
> -Niklas
>
> --
> Niklas Laxstrm
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l


_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


tchay at wikimedia

May 17, 2012, 10:11 AM

Post #12 of 15 (209 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

Hmm maybe technically. But the way namespaces are implemented in PHP 5.3 is very simple (that's part of the reason they chose the forward slash separator). HipHop can be easily upgraded to support it if it hasn't been done already.

I guess the only sure way is to compile some test scripts in HH. There might be some edge cases they missed. :-)

On May 17, 2012, at 9:59 AM, Platonides wrote:

> Wouldn't that make it incompatible with hiphop?
>
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l


_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


preilly at wikimedia

May 17, 2012, 10:25 AM

Post #13 of 15 (204 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On Thu, May 17, 2012 at 10:11 AM, Terry Chay <tchay [at] wikimedia> wrote:

> Hmm maybe technically. But the way namespaces are implemented in PHP 5.3
> is very simple (that's part of the reason they chose the forward slash
> separator).



I think you mean the *backslash* (\) character.



> HipHop can be easily upgraded to support it if it hasn't been done
> already.
>
> I guess the only sure way is to compile some test scripts in HH. There
> might be some edge cases they missed. :-)
>
> On May 17, 2012, at 9:59 AM, Platonides wrote:
>
> > Wouldn't that make it incompatible with hiphop?
> >
> >
> >
> > _______________________________________________
> > Wikitech-l mailing list
> > Wikitech-l [at] lists
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


lists at nadir-seen-fire

May 17, 2012, 10:55 AM

Post #14 of 15 (207 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

An initial \ is only necessary if you add a namespace to the top of the
file.

Changing a class to use a namespace also completely changes it's class
name and breaks all code depending on that class, namely extensions. And
there is absolutely no good reason to add a namespace to existing code
strong enough to outweigh the fact that we'll be breaking extensions.

So I see absolutely no reason to go adding \ into files.

--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]

On Thu, 17 May 2012 10:00:28 -0700, Terry Chay <tchay [at] wikimedia> wrote:

> We probably should consider prefixing TLD classes (like SPL Iterators
> and such) with a \ just to be compatible with namespacing down the road.
>
>
> On May 17, 2012, at 3:13 AM, Niklas Laxström wrote:
>
>> On 17 May 2012 01:36, Jeroen De Dauw <jeroendedauw [at] gmail> wrote:
>>> Hey,
>>>
>>> I am not aware of any guidelines regarding the usage of PHP namespaces
>>> in
>>> MediaWiki and di not find any on MediaWiki.org. Not surprising since
>>> 1.20
>>> is the first release in which we can actually use it. So I'm curious on
>>> peoples thoughts on how to use this new features, if at all, in core
>>> and in
>>> extensions. As far as I get it, we cannot simply put it into core
>>> without
>>> breaking compat all over he place, but could gradually introduce it
>>> for new
>>> components. For new extensions it's a lot easier of course, which
>>> happens
>>> to be the use case I'm currently facing, and wondering what to best do.
>>> MediaWiki\ExtensionName seems like a reasonable NS for extension
>>> classes.
>>
>> I just came across to a reference to PSR-0 while researching another
>> unrelated thing.
>> Little bit of googling gives this: https://gist.github.com/1234504
>>
>> Seems to be somewhat relevant to this discussion, although pretty much
>> incompatible with what we do in MediaWiki currently.
>> -Niklas
>>
>> --
>> Niklas Laxström

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


tchay at wikimedia

May 17, 2012, 11:50 AM

Post #15 of 15 (207 views)
Permalink
Re: Stance on PHP namespaces? [In reply to]

On May 17, 2012, at 10:25 AM, Patrick Reilly wrote:

> On Thu, May 17, 2012 at 10:11 AM, Terry Chay <tchay [at] wikimedia> wrote:
>
>> Hmm maybe technically. But the way namespaces are implemented in PHP 5.3
>> is very simple (that's part of the reason they chose the forward slash
>> separator).
>
>
>
> I think you mean the *backslash* (\) character.
>

Yes.

I'm specifically referring to the fact that global namespacing is automatic in the case of functions, but not in the case of classes themselves. So things like stdClass need to be \stdClass IF at a later point you decide to put a topline namespace in front of the file.

If we're really 5.3 only, then it can't hurt to do that for built-in classes now.

If we're not, then this breaks BC with 5.2
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.