Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98804 invoked by uid 1010); 9 Aug 2005 18:03:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98789 invoked from network); 9 Aug 2005 18:03:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Aug 2005 18:03:02 -0000 X-Host-Fingerprint: 64.233.184.205 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.205:1708] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id A1/66-04646-6DFE8F24 for ; Tue, 09 Aug 2005 14:03:02 -0400 Received: by wproxy.gmail.com with SMTP id i21so1021433wra for ; Tue, 09 Aug 2005 11:02:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NyeVe6lqWNQ044nh/SWxgpvLpoeX5KoixfBUpLBastPT6s6YpUhP5kbNk1WpjyAQAUL2DK1UYNKrGlhDgwTvamsmCyH24W6hHg3VwCX8uJsZURmewHp3pTbzPEldjVTswXjWB9+EjQnyTmU00aC5zGO9TMv6nZdPNaePxy+AHQQ= Received: by 10.54.7.21 with SMTP id 21mr5633087wrg; Tue, 09 Aug 2005 11:02:59 -0700 (PDT) Received: by 10.54.153.5 with HTTP; Tue, 9 Aug 2005 11:02:58 -0700 (PDT) Message-ID: <4e89b42605080911024a54dba1@mail.gmail.com> Date: Tue, 9 Aug 2005 14:02:58 -0400 To: Andi Gutmans Cc: Pierre-Alain Joye , internals@lists.php.net In-Reply-To: <5.1.0.14.2.20050808230407.031dcdb0@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <5.1.0.14.2.20050805135145.0366f820@localhost> <20050808093208.185bb60b.pierre@dotgeek.org> <86.75.04646.14887F24@pb1.pair.com> <5.1.0.14.2.20050808143433.031b9d00@localhost> <20050809074459.08d67d48.pierre@dotgeek.org> <5.1.0.14.2.20050808230407.031dcdb0@localhost> Subject: Re: [PHP-DEV] Re: RC1, instanceof? From: kingwez@gmail.com (Wez Furlong) Maybe a little late throwing my 2 cents in, but here they are anyway. If you're writing an app that can optionally use a component that is not present, there is nothing conceptually wrong with calling instanceof to determine if that support is present; PHP should not blow up. If the class is not loaded, then the object can't possibly be an instance of it, therefore the operator should return false. --Wez. On 8/9/05, Andi Gutmans wrote: > You are wrong because __autoload() *is* called and you can load the class > on the-fly. The only problem is if the class does not exist in your code > base, in which case, your application should blow up! >=20 > Andi >=20 > At 07:44 AM 8/9/2005 +0200, Pierre-Alain Joye wrote: > >On Mon, 08 Aug 2005 14:43:25 -0700 > >andi@zend.com (Andi Gutmans) wrote: > > > > > I don't agree that instanceof on a class which doesn't exist > > > should work. It doesn't do so in other languages (or at least not > > > in Java/C++(dynamic_cast)) nor does it really seem to make a lot > > > of sense and be useful. Sounds more like an edge case you have > > > hit with some weird code which can probably be written > > > differently. > > > >You cannot compare PHP with Java and C++ in this case, sorry. They > >work differently for known reason (compiled being one). > > > >If you have a method, which could be a factory, or the behaviors > >depends on which object it gets, you have now 2 choices: > > > >- Accept to live with a possible fatal error > > > >- Include all single classes you are going to check, even if you > > will use none of them. > > > >The 3rd possibility, fix instanceof. > > > > > Today, fetching of classes in the language is very generic, and > > > they have to exist. I see very few cases where this would not be > > > true if you are writing a regular application. In those few cases > > > where you are doing something extremely weird, you can use > > > reflection to introspect an object. > > > >Agreed, that's fetch_class is not opportun for instanceof. My point > >is not about the fetch_class is done but the way instanceof works. > >Reflection is terribly overkilled for such a need, and slow. > > > > > There is no way this would be changed for RC1 (or PHP 5.1) > > > because it's a significant change which would affect many places > > > and not only instanceof. I personally think it shouldn't be > > > changed at all. If you're referencing classes/exceptions in your > > > code that don't exist, then something is very bogus with your > > > code. Don't use a NonExistantException if that could happen, use > > > Exception... > > > >Agreed here too, not related to instanceof though. > > > > > >--Pierre > > > >-- > >PHP Internals - PHP Runtime Development Mailing List > >To unsubscribe, visit: http://www.php.net/unsub.php >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >