From: Simon Schick [mailto:[email protected]]
> >
> > I consider interchangeable only three cases:
> > 1. Numerical string.
> > 2. Integers and floats as strings.
> > 3. Integer and string 0 1 as bool.
> >
> > Any other cases should error out.
>
> Until now I thought about the weak variable-types as a order ...
> string, float, integer, Boolean.
> All Boolean values are compatible be an integer (0 or 1) and all
> integer are compatible to a float and so on. Do you think it's
> good to have it this way? This would mean that you could also get
> a Boolean true as string "1" ... I personally don't like that ...
> but I don't know where to draw the strict-line.
> Now think about that backwards. Can a "1" be passed as a parameter
> that expects Boolean? If yes, I'd keep it consistent in both ways.
>
> Bye
> Simon
Conversion the other way is essential. Consider the following URL:
http://example.com?foo=1
In your PHP script $_GET['foo'] === '1' (a string).
In fact, nearly every input to PHP is a string. This is why PHP was designed with some seriously
robust type juggling on scalars. Any typing proposal that wants to actually pass a vote is going to
have to allow appropriate implicit conversions from string to other types.
John Crenshaw
Priacta, Inc.