On Fri, 28 Mar 2003, Andi Gutmans wrote:

> The point of type-hints is to be able to catch errors in your code
> quickly and not having to write checks, the point isn't to catch
> problems in your code at run-time. And as I said before, if it doesn't
> suite you then don't use type-hints and use instanceof like you would
> have done 2 weeks ago.  It's not a disaster so don't make it sound
> like one. So much has changed in the past two weeks? If you need to
> catch errors because you are writing something generic such as SOAP
> (which most of the PHP community doesn't do) then go ahead and do the
> instanceof's you need to do.

The point is that the SOAP (or whatever) library will be interfacing
with code written by others.  If those other people use type hints and
it blows up with an E_ERROR, we don't have a nice way to handle this
error and continue serving.

This *is* a disaster, because we are introducing a feature that appears
to be quite nice at first glance, but causes portability issues with
peoples scripts; for instance; PEAR scripts that use type hints will
immediately be incompatible with a larger application framework.
Therefore, PEAR should not use type hints if it wants to remain
portable.

The same applies to all script libraries.

> Exceptions have a potential of leaking memory. I have mentioned in the
> past that I wouldn't base my applications logic on exceptions but only
> use it in error conditions to clean-up and/or give a nice message. You
> are talking about using it as part of your application logic.

What is the point of structured exception handling if you are not
supposed to use it to code the logic to handle run time errors?

> You are convincing me more and more not to throw an exception with
> type hints.

And you are convincing me more and more that the OOP and error handling
model in PHP5 will continue to be half-assed for a long time to come :/

What is *so* wrong with throwing an exception from type hints?  It will
still cause the script to bail out if the exception is not caught (which
will keep you and the novice programmers happy), and it allows more
advanced programmers to apply PHP in more and more advanced ways.

--Wez.


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

Reply via email to