Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59358 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82221 invoked from network); 5 Apr 2012 23:35:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2012 23:35:00 -0000 Authentication-Results: pb1.pair.com header.from=ww.galen@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ww.galen@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.170 as permitted sender) X-PHP-List-Original-Sender: ww.galen@gmail.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:44526] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/98-30259-22C2E7F4 for ; Thu, 05 Apr 2012 19:34:59 -0400 Received: by iaeh11 with SMTP id h11so2933029iae.29 for ; Thu, 05 Apr 2012 16:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=RCqNQv8mZ2Y7v57+6FhRqdST8ZkqyYkAE8OkOqeuNqY=; b=fQfZzK2Yjs5hPutLFY/aBNyYt/DspXKmILo3o5J1WAZTgmZXsIcbpdhqkETILD1NH1 bm3jCyZA3e4sQ7kejuCSpV65awrt3g2T3j07umH0cbdoFT2S21asutSphsKi4CJYn37h EpyoRgaIViLnAsSIdprxXfDSu0GRLAoRPLwI4S7ASiR8q5aUwGZht11p2cPsARc3J3Rp kkekROqidMRebkfyL5lecUdtcY+AnXcVFPKSDF3DHcbgDjJwIXb51K/+Y8Q2DS3fUkdQ Rl15ZzfizgXQ1Rtx4eL+NPzDRzjxbSwziuDLfV5xdHlyz184W9tNqEu22vBTpPtbcqlZ 8wYw== Received: by 10.50.189.129 with SMTP id gi1mr3628288igc.16.1333668895427; Thu, 05 Apr 2012 16:34:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.164.132 with HTTP; Thu, 5 Apr 2012 16:34:15 -0700 (PDT) In-Reply-To: <4F7E1FB8.7020108@sugarcrm.com> References: <2FD77C3003DC4656BCF6309B097DD978@gmail.com> <4F7E1FB8.7020108@sugarcrm.com> Date: Thu, 5 Apr 2012 16:34:15 -0700 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=14dae9340a83c28ddb04bcf6fcdc Subject: Re: [PHP-DEV] resume after exception From: ww.galen@gmail.com (Galen Wright-Watson) --14dae9340a83c28ddb04bcf6fcdc Content-Type: text/plain; charset=ISO-8859-1 2012/4/5 Stas Malyshev > Hi! > > >> it's a wonderful mechanism with more uses than simply reporting errors > >> - the aspect of transferring control is what I find really interesting > >> about exceptions. > > Exceptions should not be used for flow control. [...] > > While exceptions themselves may not be suitable for a general-purpose control structure, they do embody one. It's an early-return mechanism that you also see in some of the other control structures mentioned in this thread (Python's generators, Common LISP's conditions). Even the "return" statement itself could be considered a simpler form of it, with the difference that "return" can only go up a single invocation while "throw" can exit an arbitrary number of them (also, "throw" is limited in the type of value it can return). The argument against any early-return mechanism is that it creates a too-complex control flow. This is the same argument from the structured programming wars about having multiple exit points from a function, in support of having a single return at the end of functions. It certainly can produce messy, hard to understand code, but it can also be quite powerful, simplifying certain problems. Perhaps there's some middle ground that balances clarity, simplicity and power. --14dae9340a83c28ddb04bcf6fcdc--