Re: Re: RC1, instanceof?
| From: | George Schlossnagle | Date: | Tue, 09 Aug 2005 18:07:27 +0000 |
| Subject: | Re: Re: RC1, instanceof? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-17710@lists.php.net to get a copy of this message | ||
On Aug 9, 2005, at 5:56 AM, Pierre-Alain Joye wrote:
On Tue, 9 Aug 2005 10:15:15 +0200 (CEST) derick@php.net (Derick Rethans) wrote:To duplicate the old semantic now you need to do: if(class_exists('MyFoo') && $obj instanceof MyFoo) { } which is definitely uglier than if(is_a($obj, 'MyFoo')) {} GeorgeOn Tue, 9 Aug 2005, Pierre-Alain Joye wrote:function wrapperFoo($obj) {But you're testing for something that you *know* that can not exist in your code base. That is a broken test, so it should throw a fatal error.This technique is already frequently used to cope with lazy loaded code, which even with cached code compilers, is pretty damn efficient in a scripted language (less IO operations, less parsing, less memory...) It is not about the fact we 'can' load the class, but that we dont 'want' to load the class.. - it's a waste of resources, memory, cpu etc. just for the sake of CS perfection.. Last time I looked PHP was about getting thing done efficiently, not about giving your university professor a woody... ;)That's my point. The autoload magic (crap? :)) is not in cause here. If you _test_ something, you do not expect the test operator to abort your execution (fatal error).if (is_a($obj, 'MyFoo') { } ... other tests ....} worked before is_a was deprecated. function wrapperFoo($obj) {if ($obj instanceof MyFoo) { }}