Re: Why no overloading in PHP5?
From: Ashmodai (ashmodai_at_mushroom-cloud.com)
Date: 01/30/05
- Next message: Ashmodai: "Re: PHP scripts and IE"
- Previous message: Ashmodai: "Re: Need some ideas"
- In reply to: Terje Slettebų: "Re: Why no overloading in PHP5?"
- Next in thread: Michael Fesser: "Re: Why no overloading in PHP5?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 03:09:53 +0100
Terje Slettebų scribbled something along the lines of:
> "Michael Fesser" <netizen@gmx.net> wrote in message
> news:e6edv0dfabi0db38u0qqm0d4kuq3kb2tbm@4ax.com...
>>In some cases you can solve such issues with interfaces.
>
>
> Yes, for regular function calls. However, if you have a function like:
>
> function add($a, $b)
> {
> return $a + $b;
> }
>
> then without operator overloading, this function simply can't work for
> objects of user-defined types (classes).
Yes, but PHP has only recently evolved into a (less or more) OOP
language and was never meant to care about types.
The entire problem of user-defined types only exists when you're using
instances of classes (i.e. objects).
Without classes PHP's approach works well. Once you're using classes,
you need to be a bit more careful.
The OCP may be a bit harmed by PHP's approach, but traditional function
overloading would not work in PHP because of the way it treats types.
I think in PHP it's better to think of classes as something different
than types. An object is of type "object", so to say.
It seems awfully wrong from the perspective of a C++ or Java programmer
but we're not talking about C++ or Java anyway.
Arrays are very different from those in C++ too so I don't see what your
problem is.
As for overloading in PHP, I think the name is descriptive and correct,
but I can see why you were confused about its use.
-- Ashmo
- Next message: Ashmodai: "Re: PHP scripts and IE"
- Previous message: Ashmodai: "Re: Need some ideas"
- In reply to: Terje Slettebų: "Re: Why no overloading in PHP5?"
- Next in thread: Michael Fesser: "Re: Why no overloading in PHP5?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|