On Wed, Feb 06, 2008 at 06:47:23PM +0100, Stefan Priebsch wrote:
> Sam Barrow schrieb:
> > If anyone has any objections to a scalar type hint please raise a
> > valid point.
> 
> Chris Stockton schrieb:
> >This library would probably have ~300(String) + ~110(Int)
> >~40(Resource) ~30(Bool) ~10(Float) = 500 less function calls, and much
> >cleaner code if there was type hinting.
> 
> I may be short-sighted here, but does type adding hinting not just push 
> the problem to the library user? In strictly typed languages the 

Ah, it depends on what you see type hinting for ... which is why I am not
sure how good the above tests are. Type hinting does not obviate
application type testing of fields from forms (which are all strings), that
still needs to be done. Type hinting is for 'lower level' code that expects
its arguments to be of certain types ... it is to catch the code where a
programmer accidentally (or lazily does not check) passes the wrong type ...
if this were not checked untold problems could arise in obscure places.

> compiler enforces type consistency, in PHP any type inconsistency yields 
> a runtime error, thus forcing the library user to explicitly type cast, 
> wrap every library call into a try-catch statement or use a runtime 
> error handler (which in turn can throw an exception, taking us back to 
> try-catch)?
> 
> From an overall perspective on the PHP code, I would rather have the 
> type checks _once_ inside the functions/methods, instead of multiple 
> times on every call.

But you are assuming that you can identify the 'right' places to put the
checks ... not always easy, especially in code that changes.

-- 
Alain Williams
Linux 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
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

Reply via email to