Re: type hinting
| From: | Sam Barrow | Date: | Mon, 07 Jan 2008 18:32:31 +0000 |
| Subject: | Re: type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34592@lists.php.net to get a copy of this message | ||
On Mon, 2008-01-07 at 19:21 +0100, Stefan Priebsch wrote:
> Sam Barrow schrieb:
> > Keep in mind that your "do_whatever" would actually be a trigger error
> > with an error message including the name of the function and parameter
> > number.
>
> I did not make the point of my code clear enough. do_whatever is not the
> code that triggers the error, but the code that handles the error.
>
> My point is that I think people will start checking parameters before
> they call a function to avoid a fatal error. This is more code and
> uglier, because you'll have to repeat it for every function call,
> instead of once in the function body.
True, this is why I don't think an incorrectly typed parameter should be
fatal, just a warning or recoverable.
> Even if they put an explicit typecast into a function call, like
> foo((int) $something) error handling code would have to be provided in
> case the cast was not possible.
> Regards,
>
> Stefan
>
> --
> >e-novative> - We make IT work for you.
>
> e-novative GmbH - HR: Amtsgericht München HRB 139407
> Sitz: Wolfratshausen - GF: Dipl. Inform. Stefan Priebsch
>
> http://www.e-novative.de - GnuPG Key: 0x7DB67F7F
>