Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85405 invoked from network); 2 Sep 2012 00:27:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 00:27:10 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.220.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:42757] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/EA-17065-BD7A2405 for ; Sat, 01 Sep 2012 20:27:09 -0400 Received: by vcbgb30 with SMTP id gb30so4894395vcb.29 for ; Sat, 01 Sep 2012 17:27:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=sjvivKIlLyWWAKbzv13OJrjRiRoADMThh0eB6uzwF6U=; b=PVPfkW5roygfWk+JqSRlnDcxCX/zPHfCFmWzXFEAKBjA0fY56oEi0zma/wuAVw7DOn 7+vzgbpJpIYGbj3b1k/Uo3OE9iEQfOCdmIHf4VNTYMrTT+WLN5lc7ifstrm9IKPX8sPK wyNizfOBExaPhItcq0KCqXJeKoiBuTTLqxLHU5tceV1bH3G2uM6WetMcWJVivhDEMTui bndNGx3fDCMKycT7u2X/NrG8SnqFuRQGAL9uvTx82N1xhmRpLLF1BsPg6q/MTdzCkWUK ejQVF191ZCLyZ/fNeiwWpdPVKw6AVoZS8dn1i5Ktg0OnRUIkHaevs1R+XOHVGyTYqGWZ uoIA== Received: by 10.52.90.104 with SMTP id bv8mr7117926vdb.102.1346545625489; Sat, 01 Sep 2012 17:27:05 -0700 (PDT) Received: from [192.168.200.148] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPS id s1sm3131591vdi.14.2012.09.01.17.27.03 (version=SSLv3 cipher=OTHER); Sat, 01 Sep 2012 17:27:04 -0700 (PDT) Message-ID: <5042A7D6.7050001@lerdorf.com> Date: Sat, 01 Sep 2012 17:27:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Gustavo Lopes CC: Pierre Joye , Stas Malyshev , PHP Internals References: <5040DC47.8000305@ajf.me> <5040F4D9.80206@sugarcrm.com> <5042946A.80204@sugarcrm.com> In-Reply-To: X-Enigmail-Version: 1.5a1pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlp5pozbsyvEYRi1KRC4JEr3y/DsbMEDBxmdfNaghcHzFV3XJd5GnOc4c27AdV4KrcMMudJ Subject: Re: [PHP-DEV] Re: Are exceptions allowed in php core? From: rasmus@lerdorf.com (Rasmus Lerdorf) On 09/01/2012 04:51 PM, Gustavo Lopes wrote > * In fact, if there is a unifying theme in the usage of exceptions in > PHP, is that exceptions are used when OOP interfaces are involved (see > Zend interfaces, SPL, DateTime and PDO -- though optional there). The > core vs. non-core argument only looks attractive because there are few > built-in classes in the core. I think this is drifting off-topic. Whether or not a generator is an object is an implementation detail. If I write: $things = getStuff(); foreach($things as $thing) { do_some($thing); } which is very normal PHP that you see in millions of lines of code, I would not expect to have to wrap my foreach in a try/catch here. Even if I am used to exceptions and might have: $things = getStuff(); foreach($things as $thing) { try { do_some($thing); } catch (Exception $e) { echo $e->getMessage(); } } this is still going to fatal on me eventually with an uncaught exception on the foreach if, for example, I pass the generator a second time to something and it has run off the end. This is something you don't have to worry about currently and I think it will cause headaches for people when they start passing generators around. In theory I should be able to pass a generator to any existing code that takes an array without having to worry about modifying that code to catch foreach exceptions. And yes, I know it is actually a generator exception, but to the average user it will look like it is foreach throwing. -Rasmus