Re: RE: Optional scalar type hinting
| From: | Tomi Kaistila | Date: | Thu, 03 Jan 2008 20:01:24 +0000 |
| Subject: | Re: RE: Optional scalar type hinting | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34341@lists.php.net to get a copy of this message | ||
> Broken record perhaps? I am getting a bit tired of this "just use Java
> argument", it's perhaps even a bit arrogant. From what I read there is
> plenty of people that want type hints for static types - there's a few
> patches out there, it doesn't slow down the general case. So why should
> we *not* add it? (And yes, I changed my mind)
Same here. I am getting generally tired of the attitude some
politically-correct people seem to have about writing "javaish" code. What
the heck is "javaish" code anyway? Most features that exist in both PHP and
Java can also be found in myriad of other languages and it has so far not
stopped the development team from adding a feature when it is clearly useful
and (most importantly) desired an uncounted number of people.
In fact those who oppose the feature seem only capable of doing so with
hair-splitting rhetorics.
> am I the only one to consider E_FATAL (as generated for class typehints)
> makes type hinting useless - given that there is no compile stage at which
> to catch typehint related mistakes
In principle you are correct. But E_FATAL errors should not happen in a
program that is in production use. If they do, it seems someone was not doing
their job properly.
I am not convinced throwing an exception is the best course of action. If it
was, you might make the argument that all errors should be exceptions, while
traditionally it is the other way around and changing that is beyond the
scope of this thread. I actually like the current "division of labor" when it
comes to error handling.
When PHP detects an error, it should actually be an error. Exceptions are
convenient for the code that you as a PHP developer can throw. They are
especially a blessing when writing library code. That way exceptions work for
the error management, instead of competing with it.
I say use E_WARNING at this stage. If there is some large redecorating with
PHP's error handling in the future, it can be changed then.
Tomi Kaistila
PHP Developer