Re: Scalar-type-hinting - which way is the best to go?

From: Date: Sun, 18 Mar 2012 10:56:23 +0000
Subject: Re: Scalar-type-hinting - which way is the best to go?
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 3/17/2012 11:46 PM, Marco Pivetta wrote:
Thank you for clarifying some things :)
    4. Strict weak type hinting:
This realm is the most likely to succeed because the core already does something like this for internal functions (via zend_parse_parameters). This balances utility (enforcing the type) with fundamental language design principles (juggling). You need to understand the fundamental language principles to understand why any solution MUST lie somewhere in this realm. Remember that: 1.2 === "12"; "2"+"2" === 4; substr(12345, "2") === "345"; This type juggling affects the language in all sorts of ways. For example, PHP uses '.' for concatenation (not '+' like most similar languages) which ensures that there is no ambiguity as to whether you are operating against the integer value or the string value. PHP is designed so that you generally don't have to care whether a value is ACTUALLY an integer or a string internally, it will be treated as whatever type you use it as. In PHP int(2), float(2.0), and string("2") can generally be used completely interchangeably with no variation in results whatsoever. When core devs say that "strict typing would make it not PHP anymore", this is what they mean; it would badly violate this core concept. If you want scalar typing, you need a solution that embraces this fundamental design principle.
Yeah, I don't want to start a discussion on that now nor start a (probably already repeated) war on it, but I think those principles are dead since very long time...
If you think that the essential core functionality of type juggling is "dead since very long time" you have no business making decisions on the future of PHP. PHP without type juggling is no longer PHP! Call my opinion extreme if you wish, but I believe Rasmus, the owner of the trademark on PHP, has suggested that he would not allow the name PHP to be used if it is removed. If you really, really want strong type in a PHP like language, please fork it, rename it, and go away! See if the market follows you or PHP.

Thread (13 messages)

« previous php.internals (#59000) next »