On Thu, Sep 23, 2010 at 12:24 AM, Peter Lind <peter.e.lind@xxxxxxxxx> wrote: > On 23 September 2010 02:14, Daniel Kolbo <kolb0057@xxxxxxx> wrote: > > *snip* > > > On 9/22/2010 9:11 AM, chris h wrote: > > Say you have two classes: human and male. Further, say male extends > > human. Let's say you have a human object. Then later you want to make > > that human object a male object. This seems to be a pretty reasonable > > thing to request of our objects. > > Perhaps if you're a C# programmer, but the PHP way of thinking is > radically different. > C#: This object is whatever it was currently cast to (if possible) > PHP: This object is this object, whatever it was created as > > If you have a need to make an object switch class in PHP, then there's > a 99% chance you're working against, not with the language. > +1, its more like the java paradigm than anything else afaict. maybe javascript? didnt know you could change class at runtime in c#, but then again my knowledge of the .net platform is very, very minimal, and happily so :) getting to some of the other posts in the thread and trying to find a reasonable place to address them, id like to point out that this scenario (turning a human into a male) is easily modeled w/ composition in oop. class Human { // member vars & functions here } class Male { $human = null; // Human instance __construct(Human $human) { $this->human = $human; } } javascript uses a form of inheritance called prototypical inheritance. http://en.wikipedia.org/wiki/Prototype-based_programming and other languages that support runtime class alteration (ruby, python, objc etc.) are quite different than the single inheritance model in php. that said, there are ways of modeling this problem in any of these languages (see above for 1 reasonable solution w/ single inheritance in php). one of the problems w/ the runtime class alteration model is how do you determine the class of an object after altering it at runtime? -nathan