Re: Type hinting

From: Date: Fri, 28 May 2010 09:42:25 +0000
Subject: Re: Type hinting
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-48547@lists.php.net to get a copy of this message
Lukas, Etienne, Hannes: You all pointed out the issues and enhansments that can be done. Basic thing I want to say that type hinting and data casting should be done in tandem and work the same way. So generally there is a need to rething how type casting works and implement enhansments with adding type hints. (int)42 = array(42) is a good point, it works now. With type hinting it makes a catchable fatal error. So there is a question - make type hints follow the cast rules, or cast rules should follow current type hinting rules. Because although I don't see a problem in remembering that $int = (int)"123abc" works fine and function a(int $int) {} a("123abc"); fails with an error. But some argue to the ground that it should cast also, or implement a strict type hinting (witch in my opinion isn't for PHP, it's not in its nature, and I want PHP to evolve it's own way, not to become a twin for Ruby, Python, etc), because they don't want to remember rules for the type hints (btw, if you can code PHP, C# and Python, you should have quite good memory and some additional easy rules to remember isn't such a big thing).

« previous php.internals (#48547) next »