On Mon, 2005-08-08 at 23:08 -0700, 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!

The basic point is that is_a() provided negative testing of non-existant
classes
if (!is_a($obj, "SomeRarelyUsedClass")) { ....

instance_of does not, and can not, at present. 

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... ;)

Regards
Alan


        
> 
> Andi
> 
> At 07:44 AM 8/9/2005 +0200, Pierre-Alain Joye wrote:
> >On Mon, 08 Aug 2005 14:43:25 -0700
> >[EMAIL PROTECTED] (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
> 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to