At 11:55 PM 8/8/2005 +0200, Lukas Smith wrote:
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.
Those languages are alot less dynamic at runtime compared to PHP. So I
dont think this is a valid argument.
A common scenario (which I personally dont like) but what is done:
- PEAR.php is loaded on error to generate an instance of PEAR_Error
- inside the code you check for an instance of PEAR_Error being returned
- obviously when no error ever occured you never loaded PEAR.php and kaboom
You are right, I don't like it either, and it doesn't explain why it's needed.
A dynamic language and dynamically typed language doesn't mean that
everything should be dynamic if it doesn't make sense. Only what is
necessary should be dynamic and in this case, I have yet to see a
convincing argument of why cleaner static structure is worth changing to
something dynamic. There are other instances, especially in PHP 5's new OO
implementation, where we took a more static approach as it makes more sense
and can be better optimized.
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...
Well the easy solution is to simply undeprecate is_a().
I don't mind, but I'm planning on rolling RC1 soon so not sure it'll make
it in. If people agree to un deprecate it I don't mind doing it post RC1 as
chance of something breaking is slim. I still think it's for the wrong
reasons though... You deserve an E_STRICT ;) (just kidding)
Andi
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php