Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34400 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9085 invoked by uid 1010); 4 Jan 2008 10:56:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 9069 invoked from network); 4 Jan 2008 10:56:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2008 10:56:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 213.152.38.186 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 213.152.38.186 freshmint.phcomp.co.uk Linux 2.5 (sometimes 2.4) (4) Received: from [213.152.38.186] ([213.152.38.186:61236] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/37-20810-1C01E774 for ; Fri, 04 Jan 2008 05:56:02 -0500 Received: from addw by mint.phcomp.co.uk with local (Exim 4.67) (envelope-from ) id 1JAkDW-0007Rm-Os; Fri, 04 Jan 2008 10:55:58 +0000 Date: Fri, 4 Jan 2008 10:55:58 +0000 To: Gregory Beaver Cc: internals Mailing List Message-ID: <20080104105558.GC7861@mint.phcomp.co.uk> References: <477DB7BF.10201@chiaraquartet.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <477DB7BF.10201@chiaraquartet.net> User-Agent: Mutt/1.4.1i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] type hinting From: addw@phcomp.co.uk (Alain Williams) On Thu, Jan 03, 2008 at 10:36:15PM -0600, Gregory Beaver wrote: > Hi all, > > As someone who has dealt with many scripts written by others as well as > many of my own in a large-scale project (PEAR). I can say with absolute > certainty that scalar type hints would not make my job easier. > > In fact, it would make it harder. Many of the functions I work with > require varied input and almost always require some kind of validation > of that input. A built-in procedure that would either end execution > with a fatal error or suddenly jump execution to a global error handler > that has no idea of the context in which the error was triggered is > almost as useful to me as a PHP extension that runs the pump on an You are missing the point. If you want your function to take an argument of arbitrary type, then you simply don't give a type hint[**] [**] I suppose that we might implement the type hint 'mixed' which would have the same effect as no type hint. Some people might like this from the 'internal documentation' point of view. > Where is the increased value? Saving a few keystrokes of validation? > No. You still need to validate the input for range, or is_numeric() or No. The point is NOT to save input ($_GET, etc) validation -- that will still need to be done; the point is to help pick up programming errors where you accidentally get the type wrong. Granted: some idiots will use it as cheap input validation, but it is difficult to help some people. -- Alain Williams Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php Chairman of UKUUG: http://www.ukuug.org/ #include