2009/7/1 Stanislav Malyshev <s...@zend.com>:
> Hi!
>
>> The patch is available here: http://ia.gd/patch/type_hint_53.txt
>
> Technical comment: as this patch changes binary API this shouldn't happen in
> 5.3 branch. So maybe it's better to make it for 6.
>
> As for the idea itself, it is obvious that many people like it, I would just
> note that it would produce a confusion for some people due to the fact that
> true, 1, 1.0, b'1' and '1' now become incompatible values and (once you
> start using typehints, of course) you'd have to explicitly convert them.
> That would lead people to stuff their code with explicit type conversions,
> which doesn't add to code cleanness. This also means that internal functions
> and user functions would behave differently with regard to type conversions.
> --
> Stanislav Malyshev, Zend Software Architect
> s...@zend.com   http://www.zend.com/
> (408)253-8829   MSN: s...@zend.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Doesn't "stuff their code with explicit type conversions" actually
mean "perform appropriate validation and conversion on incoming data"
?

The majority of data that a program gets is either from a DB (and if
ALL your columns are varchars, well, I give up and a xxx_fetch_row
SHOULD cast to an appropriate type in my mind, but ...), from a config
file (normally all strings), $_xxx (normally all strings). Internal
values are inherently cast. How many people write ...

$some_boolean = "1"; // Set some_boolean flag to true.

No, they write ...

$some_boolean = true; // No need to document anything here as the code
is pretty much speaking for itself.


We are constantly told about GIGO and not accepting anything a user
supplies as safe, so, with that in mind, you validate the incoming
data (one way is to cast to the valid type and then check ranges,
etc.) and from then on everything is in the appropriate type.

PHP's type juggling is useful, without a doubt.

But it seems to be limited to 2 areas.

1 - Casting to strings for output.
2 - Casting to boolean for equality testing.


So they don't "perform appropriate validation and conversion on
incoming data", then you will end up with having to "stuff their code
with explicit type conversions".

That's something I'm prepared to live with.

So.

A big +1 from me to incorporate type hinting into PHP.

Regards,

Richard Quadling.
-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
I need a car : http://snipurl.com/l4pih
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to