Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34325 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79295 invoked by uid 1010); 3 Jan 2008 17:05:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79280 invoked from network); 3 Jan 2008 17:05:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2008 17:05:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=tomi@cumulo.fi; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tomi@cumulo.fi; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cumulo.fi from 81.228.8.111 cause and error) X-PHP-List-Original-Sender: tomi@cumulo.fi X-Host-Fingerprint: 81.228.8.111 pne-smtpout3-sn2.hy.skanova.net Solaris 10 (beta) Received: from [81.228.8.111] ([81.228.8.111:41191] helo=pne-smtpout3-sn2.hy.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/E0-20810-ED51D774 for ; Thu, 03 Jan 2008 12:05:35 -0500 Received: from [192.168.1.3] (84.250.46.16) by pne-smtpout3-sn2.hy.skanova.net (7.3.129) (authenticated as kaisto-9) id 471A5695003D73D3 for internals@lists.php.net; Thu, 3 Jan 2008 18:04:49 +0100 Organization: Cumulo Studio To: internals@lists.php.net Date: Thu, 3 Jan 2008 19:03:01 +0200 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200801031903.01980.tomi@cumulo.fi> Subject: RE: Optional scalar type hinting From: tomi@cumulo.fi (Tomi Kaistila) Hello everyone I figured I would bring my opinion in to support of Sam's request for a more complete type hinting feature. Namely I am interested in the support for hinting scalar types on function and method arguments and I am sure it is safe for me to say that I speak for a lot of people. Most people that I know find the current type hinting, while useful, ridiculous because it looks like the job was left unfinished for whatever abstract reason. In my opinion type hinting should definitely be allowed for scalar values. As for return types, I am not so sure. So far I have found no use for such a feature in my own code, so I won't comment on it. If it is added, I welcome it for those who find it useful but if it is not added I will not loose sleep over it. > I was thinking at something along the lines of objects also for instance: > $i = new Integer(33); After my own experiments with the subject I concur that while it can be made to work, it is not only a bad idea (for the reasons mentioned earlier) it is also redundant and just unnecessary. There is a lot better way to accomplish the same and that by allowing scalar values to be hinted. It is simpler, cleaner, and easier to implement. > What if type hinting just generated an E_NOTICE. Nothing more for the > time being. Changing it to E_NOTICE or E_STRICT defeats the purpose somewhat since if I write a piece of code that hints that the argument for a-whatever method needs to be an integer it seems useless if the user of my library can avoid the issue just by supressing lesser errors and those who do not need to write extensive error handling code to respond to this sort of error (if they indeed deem it necessary to do so). While hinting is, and should remain, optional, when it is used it should be enforced. After all the user of my library has the option to dump it and go for another library that does not force types. That is the beauty of having options. Tomi Kaistila PHP Developer