On Thu, Jan 03, 2008 at 07:36:48PM +0100, Markus Fischer wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> Alain Williams wrote:
> > On Thu, Jan 03, 2008 at 12:21:21PM -0500, Sam Barrow wrote:
> >> I think E_WARNING would be appropriate. That's what happens when you
> >> omit an argument to a function right?
> >
> > The other thing to note about type hinting is that it could result in
> > faster code.
> > The value is checked and if needed converted (eg string -> integer) when the
> > function is called; it then need not be converted again when it is used in
> > the function. This will presumably be a win if the value is used more than
> > once.
>
> I don't think that automagic conversion of types is a good idea.
>
> When the type hint says I want an integer, then only integer should be
> accepted; no casting should be done. It may give predictable results
Maybe the type checks should be stricter than normal.
What are we going to want here ?
* integer - possibly convert from:
- string, in which case we just accept digits with an option + or -
The important thing is that the *entire* string must convert
- float - the standard truncate towards zero
Nothing else
* float - possibly convert from:
- integers - standard convertion
- string - accept a float in the standard formats
The important thing is that the *entire* string must convert
* boolean. At first glance this is easier as the convert to boolean for
lots of types is well defined. In most cases the programmer would
not be interested in a type check, so if he specifies it then we
should be very restrictive.
* string - possibly convert from:
- integers & float - standard convertion
- boolean - standard convertion
- objects - only if they have a __toString() method
--
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