Re: Proposal for aggregation vs. MI
| From: | Andi Gutmans | Date: | Wed, 10 Apr 2002 21:26:39 +0000 |
| Subject: | Re: Proposal for aggregation vs. MI | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82517@lists.php.net to get a copy of this message | ||
PHP isn't a compiled language and we aren't going to start adding casting, v-tables and so on.
PHP is extremely loosely typed and doing $obj->foo calls the method "foo" on $obj. This also allows for things like:
$blah = "foo";
$obj->$blah;
and so on.
I really think that people who are looking for strict typing, v-tables, and so on should be looking at languages such as Java, C# and C++. (Although each one of these also has their quirks).
Sorry to be so blunt but I don't want to see PHP changed into yet another hard to use strongly typed compiled language.
I want to keep its spirit.
Andi
At 00:25 11/04/2002 +0300, Lauri Liinat wrote:
If you want to access an aggregated object directly you can do: $obj->Timer->method(); well, that's exactly what shouldn't be done and what polymorphism is trying to eliminate... consider a huge code library which operates on an object of class Timer and that we want to reuse this library. now if we hand it an aggregated object whose method() points to the wrong method() we would have to search-and-replace, that is, more or less manually change all occurences of ->method(); into ->Timer->method(); - would you say this is feasible?? the whole idea of polymorphism is to allow both implicit reuse and implicit growth of code base. if a technique that is supposed to head towards code reuse requires a single implicit call to be manually hunt down and changed into an explicit one, then it's quite useless i'd say... having MI and casts you would simply: big_hairy_library_call( (Timer) $MI_obj ); ...and be done with it. as a bonus, you get to sleep the whole night instead of searching-and-replacing text in somebody else's library till the early morning... nothing personal, just trying to provide a scenario :) lauri -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php