Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79042 invoked by uid 1010); 26 Oct 2005 17:18:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79027 invoked from network); 26 Oct 2005 17:18:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Oct 2005 17:18:16 -0000 X-Host-Fingerprint: 66.249.82.207 xproxy.gmail.com Linux 2.4/2.6 Received: from ([66.249.82.207:16861] helo=xproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id B8/FD-22886-85ABF534 for ; Wed, 26 Oct 2005 13:18:16 -0400 Received: by xproxy.gmail.com with SMTP id t11so243733wxc for ; Wed, 26 Oct 2005 10:18:12 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=lKGNrmh6SIlwK2g8/e6SD64fI61h2HIdTTXi2+OH1SDjKYjWVsFYM8JWQnIyh3eckE2sWy3/gn6EP0mdEodbZ219EpWoImxwfo6DYh7RVRfFF4kDVihKzuWtw0E4P54UTkHz7zc3ckKsOrVvlMyVqjPdLwZPH9U3xoWvZCThOI4= Received: by 10.65.192.13 with SMTP id u13mr852801qbp; Wed, 26 Oct 2005 10:18:12 -0700 (PDT) Received: by 10.64.183.1 with HTTP; Wed, 26 Oct 2005 10:18:12 -0700 (PDT) Message-ID: <4e36d31d0510261018t639c472x9efaaf7af61a9ddb@mail.gmail.com> Date: Wed, 26 Oct 2005 10:18:12 -0700 To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: foreach with null From: buddhahead@gmail.com (Sebastian) > Any opinions? Good code is code that's easy to debug (among other things). By removing the "Invalid argument supplied for foreach()" warning without providing mechanisms to turn it on, debugging code will be more difficult. Logically speaking, when does it make sense to iterate over something that isn't an array? If I were writing one-time use scripts that I will never use again (not likely) this might be desired behavior. If I were writing code that is used by other programmers, paying users, and under conditions likely to change (implying changing code, and often debugging and testing), the ability to detect errors as early as possible is vital (The Pragmatic Programmer is a good reference for this). Most people don't want to spend more time than is necessary to troubleshoot code. Probably more importantly, managers and customers don't want to wait longer for a product they're paying for. Understandly, PHP aims to be "easy" in so many ways, but I believe in order for PHP to survive in the enterprise and allow users to easily write good code, it *must* support such features. Without features like these, writing PHP won't be so easy because the work required to do the checking is forced on the programmer. The "Invalid argument supplied for foreach()" warning should not be removed unless it can be done without breaking compatibility and with a way to optionally turn it on/off. I think we can learn a good lesson from Perl on this one. Here is how we turn on/off warnings, lexically: use warnings; - sebastian