On Fri, Jul 10, 2009 at 10:57:22AM -0400, Alban wrote: > Le Fri, 10 Jul 2009 14:23:24 +0100, Alain Williams a écrit : > > > On Fri, Jul 10, 2009 at 08:45:55AM -0400, Alban wrote: > >> Hello all, > >> > >> I don't understand why you focus on " Strict / Weak " question. > > > > It is really about: > > > > * type checking and enforcement > > or > > * type casting and generation of an error if the value cannot be > > converted cleanly > > Thank for your response ! > > I vote for throw an exception if data type won't match. Have one error > when you make a mistake is better than have a silently casting which can > transform your data in another form than what you want.
I think that we need both. * Strict enforcement is useful. * Doing silent type casting can be useful, a naive example is: is_child($_GET['age']) The GET argument here should always be integer, however if it is in $_GET it will be a string. NB: I am not advocating the above to be a way of avoiding checking what there is in $_GET - however many PHP users will use it as such. If casting (with errors) help to avoid silent errors - then so much the better. > And Exception is better than an Error because this give one chance to > programmer for resolving the problem before program be halted. Not everyone understands try/catch. Perhaps a user supplied function_argument_error() could be called if not in a try/catch block. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php Past chairman of UKUUG: http://www.ukuug.org/ #include <std_disclaimer.h> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php