Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12099 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27838 invoked by uid 1010); 12 Aug 2004 03:28:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27715 invoked from network); 12 Aug 2004 03:28:56 -0000 Received: from unknown (HELO newweb.akbkhome.com) (202.81.246.113) by pb1.pair.com with SMTP; 12 Aug 2004 03:28:56 -0000 Received: from develop ([192.168.0.40] helo=akbkhome.com ident=alan) by newweb.akbkhome.com with esmtp (Exim 4.33) id 1Bv6Jx-0005TN-8v; Thu, 12 Aug 2004 11:32:05 +0800 Message-ID: <411AE454.4060808@akbkhome.com> Date: Thu, 12 Aug 2004 11:30:28 +0800 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040422 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dan Ostrowski CC: internals@lists.php.net References: <41196A1D.6060808@velum.net> <200408112219.55268.dan@ostrowski.cc> In-Reply-To: <200408112219.55268.dan@ostrowski.cc> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] is_a() vs. instanceof From: alan@akbkhome.com (Alan Knowles) I think he's referening to something like this (which is common in pear): $x = $someobj->somemethod(); if ($x instanceOf PEAR_Error) { ....... } while that code is redundant in the case of exceptions, it is still a valid situation.. that $x may be a valid return, and PEAR_Error was never loaded.. Regards Alan Dan Ostrowski wrote: >On Tuesday 10 August 2004 7:36 pm, Hans Lellelid wrote: > > >>I like the new $obj instanceof ClassName way of checking class / >>interface types, .... but this method does have one major drawback >>compared to the old is_a() approach: >> >> The class must be loaded in order to perform an instanceof check! >> >> >> > >Isn't that the point? is_a() and instanceof are ways of checking the class of >an object at runtime where it could be any number of things. ( And here I'm >assuming you mean instantiated instead of "loaded"? ) > >If you don't have an instantiated object.. what do you have? A class! And THAT >can be checked at "compile" ( or in this case write ) time. There's something >wrong with my code, if I'm thinking of this right, if I have no idea if class >A is a subclass of class B. > >Now, if I'm passed random objects, I may want to know of which types they >are... which is where these functions/builtins come in... > >Am I misunderstanding you? > > >Dan Ostrowski > > >