PyHP_pph
PyHP_pph copied to clipboard
How should types be casted?
We can take the C/C++ approach with either (type)value or type(value) or the PHP-esque route of adding functions to the global namespace, such as to_boolean(value), to_int(value), etc.
It should be implicit, with vaguely defined rules. If, say, you have a function like this:
int Twice(int x)
{
return x * 2
}
And you pass it something that's not an int, say... a boolean:
$Result = Twice(True);
Console.StandardOutputStream >> disp($Result) >> Console.Characters.EndLine;
Then it should convert from boolean to int in an odd, unclearly defined way. In this case, I'd guess the output would be:
2
But it could also be:
0
Or:
example.pyph_pph:1:16: error: Cannot convert boolean to int.