> PHP may be a hybrid language, but the fact is you're implementing object
> oriented functionality, and as such should be implementing it in a way that
> follows de-facto standards in object oriented language design. I should be
> able to overload your internal array object, and yes, arraysshould be
> objects.

Why should _all_ arrays be objects?  Because that's the way Java and
.NET do it?  Should PHP then take it one step further and adopt the OO
model where all primitive data types become objects as well, so you can
overload an Int, Char, or Float?  That seems to be the logical extension
of your argument, and not only is it incompatible with PHP's hybrid
nature, it'd be a downside for adoption of the language as a whole.  One
of the reasons PHP has the penetration that it does is that it has a
very low barrier to entry, you don't _need_ to be an OO programmer, or
even know what object oriented programming is, to write effective,
efficient PHP scripts and applications that solve a task for you.

If you _want_ to use an Array object, there's one available in the SPL,
ArrayObject.  Breaking everyone's code in the name of blind obedience to
principles of object oriented programming seems silly, to say the least,
especially when there's an option already available within PHP that
allows you to use OO-Arrays.

Yes, it will be mildly irritating for people who have classes named
things like MyHelperInterface, who then break it out into
My\Helper\Interface .  Of course, they could solve those problems by
breaking it out into My\HelperInterface or My\Helpers\HelperInterface
(or InterfaceHelper), and to say that that minor renaming of a class
invalidates the usefulness of PHP namespaces is like saying that
removing the ability to have a function named public() post-PHP4 (or
whenever public became a reserved word) invalidates PHP's OO usefulness.

No solution to namespacing will be all things to all people.  Lots of
people don't like the use of \ as opposed to :: (I'm one of them,
although I am convinced by the arguments the \ people have put forward
that it's necessary), but do their objections render PHP namespacing
useless?  Does the lack of multiple inheritance support render PHP's OO
useless?  No, of course not.  It's all a compromise between (sometimes)
competing desires to develop the language in a way that is most useful
to most people.

Matt

> On Thu, Nov 6, 2008 at 12:03 PM, Steph Fox <[EMAIL PROTECTED]> wrote:
> 
>> In .NET, I can stick an Array class into my own namespace, extending the
>>> System.Array type if I want to and use it in my code without issue. Why
>>> can
>>> I not do that here? Is it simply that you're so worried about backwards
>>> compatibility that you feel that you can't make the necessary changes to
>>> the
>>> language to implement something fully?
>>>
>> .NET is an object oriented language. It has something called System.Array.
>>
>> PHP is a hybrid language. It does not and hopefully never will have
>> something called System.Array.
>>
>> It's like the difference between English and Esperanto... and you're
>> telling us 'cough' should rhyme with 'cow' because that's how Esperanto
>> would have it. But English is so much easier to learn, if more difficult to
>> master, that it's become the lingua franca for the 'net.
>>
>> - Steph
>>
>>
>>
>>
>>> Dan
>>>
>>>
>>> On Thu, Nov 6, 2008 at 11:43 AM, Ben Davies <[EMAIL PROTECTED]>
>>> wrote:
>>>
>>>  > Isn't the ability to do that one of the biggest reasons for having
>>>>> namespaces? To avoid having to fill your class names with junk.
>>>>> The examples are namespaced appropriately, they tell the developer that
>>>>> it's
>>>>> a Helper for Arrays in the MyFramework framework. I shouldn't need to
>>>>> suffix
>>>>> the class name with 'Helper' to reconfirm that, just because the PHP
>>>>> engine
>>>>> doesn't like it.
>>>> "This thread really should be re-titled to "allow reserved words as a
>>>> classname or not". Then perhaps the only logical response to the question
>>>> would be so obvious that there would be no thread... oo-er..."
>>>>
>>>> I think you might be deliberately missing Dan's point here: array is a
>>>> reserved word because it is not namespaced. If the PHP native function
>>>> array() was namespaced to PHPCore\array() then Dan could create a class
>>>> or
>>>> function called array under his own namespace. This is exactly what
>>>> namespacing affords us.
>>>>
>>>> array() is only a reserved word because it is not a directly accessable
>>>> native datatype. If array() was an object Array, this wouldn't be a
>>>> problem.
>>>>
>>>> This namespaces issues highlights the very fundamental issues with PHP,
>>>> and
>>>> glib, childish responses like yours only serve to score points.
>>>>
>>>> Grow up and join the conversation.
>>>>
>>>>
>>>> Ben Davies | Lead Developer | Stickyeyes
>>>> 6th Floor,
>>>> West One,
>>>> Wellington Street,
>>>> Leeds, LS1 1BA
>>>> Email: [EMAIL PROTECTED]
>>>> 0113 391 2929 | <telephone> | Fax 0113 391 2939
>>>>
>>>> This e-mail may contain information that is privileged, confidential or
>>>> otherwise protected from disclosure. It must not be used by, or its
>>>> contents
>>>> copied or disclosed to persons other than the intended recipient. Any
>>>> liability (in negligence or otherwise) arising from any third party
>>>> acting,
>>>> or refraining from acting, on any information contained in this e-mail is
>>>> excluded. The views expressed may not be official company policy, but
>>>> instead, the personal views of the originator. If you have received this
>>>> e-mail in error please notify the sender and delete the e-mail.
>>>>
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Steph Fox [mailto:[EMAIL PROTECTED]
>>>> Sent: 06 November 2008 11:01
>>>> To: Dan; troels knak-nielsen
>>>> Cc: Larry Garfield; internals@lists.php.net; [EMAIL PROTECTED]
>>>> Subject: Re: [PHP-DEV] Call it: allow reserved words in a class or not?
>>>>
>>>>> Isn't the ability to do that one of the biggest reasons for having
>>>>> namespaces? To avoid having to fill your class names with junk.
>>>>> The examples are namespaced appropriately, they tell the developer that
>>>>> it's
>>>>> a Helper for Arrays in the MyFramework framework. I shouldn't need to
>>>>> suffix
>>>>> the class name with 'Helper' to reconfirm that, just because the PHP
>>>>> engine
>>>>> doesn't like it.
>>>> This thread really should be re-titled to "allow reserved words as a
>>>> classname or not". Then perhaps the only logical response to the question
>>>> would be so obvious that there would be no thread... oo-er...
>>>>
>>>> - Steph
>>>>
>>>>
>>>>
> 

-- 
Matt Schiros

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to