On 27/02/12 02:44, John Crenshaw wrote:
> If we can agree on some basic terminology I think it would move things 
> forward considerably. I propose these terms:
> - "Strict Typing" means the super strict old C style typing that has been 
> proven to be ridiculous in this environment because of the obvious problems 
> inherent in the fact that almost every input is a string.
> - "Weak Typing" means types in the same sense that the PHP documentation uses 
> types (for example, the docs indicate substr(string, integer), and 
> substr(12345, "2") == "345".)
> - "No Scalar Typing" should be used to indicate the current system (where 
> there is no provision for hinting at scalar types.)
I'd add a fourth class, in between weak and strict typing, where a
diagnostic is issued when the requested conversion doesn't make sense.
Let's call it sane weak typing. The following would work:

function score(int $number) {
 global $points, $total;
  $points += $number;
  $total++;
}

score(42);
score(1.0);
score("7");


but these would generate a diagnostic:
score(" Mary had a little lamb");
score( array(3, 27, 45) );
score( new stdclass );
score( fopen("myfile.txt", "w") );

(note that in some of these cases, the += operator would already produce
a fatal error)

Reply via email to