Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64423 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28488 invoked from network); 24 Dec 2012 12:09:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Dec 2012 12:09:40 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.175 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.220.175 mail-vc0-f175.google.com Received: from [209.85.220.175] ([209.85.220.175:59764] helo=mail-vc0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/29-32426-30648D05 for ; Mon, 24 Dec 2012 07:09:40 -0500 Received: by mail-vc0-f175.google.com with SMTP id fy7so7288172vcb.20 for ; Mon, 24 Dec 2012 04:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=By57ikbkSbaiAdV9HW9fuC3LVaBRGnPEjyuYVaEloig=; b=WGZDcS7X9RlIOrdXg1ktnfA4o57oKtvOQ8Zch8hVnW2BQdH3DzaMN04YUGbwc8UYVF fnvRq4LhVHHxgg1l+HdDcEbMLVlPuixwzuSPbRMZQYBwI3acxs4P6iBBpKdTuRrzmEw6 xdk0Y/eQIHwVnwR3gZA6IeSdby/7LaRdVE7OM4LsWgl20bwiLrBBwmUmmLP4w7ZXKkFp D4XpzMMveZFPWlBbmKmDqPWo6ZM9XIWB1Hhn5ccq6B4oyqgFSwYv4bD16YiYENwfyY0Y uy53/TvxJWd1GXh9QWNN5avExOY/t/5O21lCeu4Wmcbaj37+rmKk/8vDc0+IW5KoUG2z d7cQ== MIME-Version: 1.0 Received: by 10.220.230.133 with SMTP id jm5mr32785807vcb.4.1356350976733; Mon, 24 Dec 2012 04:09:36 -0800 (PST) Received: by 10.58.200.130 with HTTP; Mon, 24 Dec 2012 04:09:36 -0800 (PST) In-Reply-To: References: <50CF969D.8090707@sugarcrm.com> Date: Mon, 24 Dec 2012 07:09:36 -0500 Message-ID: To: Tjerk Anne Meesters Cc: Stas Malyshev , Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=14dae9cdc6c128b32904d19812fa Subject: Re: [PHP-DEV] Adding Generator::throw() From: ircmaxell@gmail.com (Anthony Ferrara) --14dae9cdc6c128b32904d19812fa Content-Type: text/plain; charset=ISO-8859-1 Tjerk, I've been hearing this argument from time to time and I don't understand > it; aren't exceptions created with the sole purpose of (error) flow > control? > > If so, then how can "exceptions for flow control" and "very bad idea" be > mentioned in the same sentence unless there are particular bad use cases > that are implicitly referred to when saying this? > > If not, then perhaps my understanding of exceptions needs a spring cleaning > :) Correct, Exceptions aren't supposed to be used for flow control. However, this isn't about flow control. This is about throwing the exception in the proper context. With generators and coroutines, the code that throws the exception may not actually be a child of the code that called it (from the stack's perspective). Therefore, adding Generator::throw() simply allows for throwing the exception in the proper stack frame (the framew that called the original code). For an example of how this would be useful, read this *awesome* post about coroutines: http://nikic.github.com/2012/12/22/Cooperative-multitasking-using-coroutines-in-PHP.html Anthony --14dae9cdc6c128b32904d19812fa--