On 27/02/12 16:47, Paul Dragoonis wrote:
> 2012/2/27 Johannes Schlüter <johan...@schlueters.de>
>> Hi,
>>
>> PHP is no strickt-typed language. Changing this is a massive change, if
>> you want to go there: There are plenty of other languages.
>>
>> If you want this to be an optional feature:
>> a) It's not optional (one has to maintain code written by others, uses
>> libraries, frameworks, ...)
>> b) It causes a hell lot of trouble with copy-on-write. going from
>> fixed-typed to non-fixed-typed variables (in a funciton call or
>> assignment or such) will always have to cause a copy. This will hurt the
>> performance in hardly predictable ways.
>>
>> johannes
>>
> Big +1 from me. Thanks for the post Johannes!
I also agree with Johannes, that would be too much trouble.

> It makes sense to have a type hint for the different type of data
> structures.
> 1) array
> 2) object ( class name for OOP ).
>
> The scalar values (int, string, double) are type-less, flexible and should
> remain that way. If you want strict typehinting then move to another
> language.
But I disagree with you in that string is always a scalar.

int and double being the same thing, that's ok, even though I usually have
to deal and verify for just natural numbers, but the consideration that it's
a variable of numeric type which could hold many types of numbers is
acceptable. Both are also implemented inside the zval.

Now strings. There are two different kinds of strings.
The first one $age = $_POST['age'] is the kind of string that you want to
treat as a number. And that's fine.

But you also have $name = $_POST['name'] // 'John Doe' which is wrong
to treat as a the same as $age.



---
Hello, I see you were born in <?= $thisyear - $name ?>. You look older.


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

Reply via email to