Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61027 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55962 invoked from network); 28 Jun 2012 14:20:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2012 14:20:04 -0000 Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain punkave.com designates 209.85.213.53 as permitted sender) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.213.53 mail-yw0-f53.google.com Received: from [209.85.213.53] ([209.85.213.53:43441] helo=mail-yw0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/90-52286-3186CEF4 for ; Thu, 28 Jun 2012 10:20:04 -0400 Received: by yhp26 with SMTP id 26so2513946yhp.12 for ; Thu, 28 Jun 2012 07:20:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:x-gm-message-state; bh=OjGstwRWxvaterHWu28aIe1x7+DRoLS9oN6xfx9qMgY=; b=Il4plX6wI6To9gXYgfapCDS3gBu/6zUwIl5e5DD9Cxqn3p8t7Rs59Jn+P9TCdBa13Q /HTOEwO9xQPVtePO1Rct8RIDS5HUvtmW+NOfJlj95jwOs8jgtCqpRJ270S046iwzcAqh iTfADEuIud4aWK+5we6t1Hr8IQpj1FxRMfB1oJI/PS/RMVYDA4vyN4V8+oceFHgycbpF zgNcJD2Ae+fXzEigm79O+krJQIrlhtWDJI4maqhMiovw4MQPpP/+dhbrPNxHUYfsnZ97 nJ0ls16DvKR6tYfuHivoQyRiVbsgISvqvmjqQTjlHK5TRryJVmM1pgNNSVosYoLGM1Ha pdag== MIME-Version: 1.0 Received: by 10.236.185.167 with SMTP id u27mr3649627yhm.32.1340893200077; Thu, 28 Jun 2012 07:20:00 -0700 (PDT) Received: by 10.100.141.17 with HTTP; Thu, 28 Jun 2012 07:20:00 -0700 (PDT) In-Reply-To: References: Date: Thu, 28 Jun 2012 10:20:00 -0400 Message-ID: To: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkS1/hPsNNvmwKGbfEPJmuZtmi7d8+Lcw/A42KvhFyCVHQAqJXSILOviO0qK9noBFqnNEXP Subject: Re: [PHP-DEV] Resume keyword From: tom@punkave.com (Tom Boutell) Saying that "the exception handler shouldn't have called resume" in the case where the exception was originally thrown in a deeper stack frame sounds good until you consider that this requires exception handlers to know whether the code preceding them has been refactored or not, which makes it tough to separate concerns and invites situations where it is harder than ever to figure out the side effects of what you're doing. Exception handlers ought to be able to look at the exception object alone in order to figure out what to do. On Thu, Jun 21, 2012 at 8:11 AM, Michael Morris wr= ote: > On Thu, Jun 21, 2012 at 2:59 AM, Sebastian Krebs > wrote: >> 2012/6/20 Michael Morris >> >>> [/snip] >>> >>> An example for additional clarity. >>> >>> set_exception_handler(function ($e) { >>> =A0echo $e->getMessage(); >>> =A0// Don't know if this is correct - but should be able to illustrate = here >>> =A0if ($e->getCode() =3D=3D E_NOTICE & E_STRICT) { >>> =A0 =A0resume null; >>> =A0} >>> >>> =A0echo 'Dying now'; exit; >>> }); >>> >>> throw new Exception('A test', E_NOTICE); >>> >>> echo "We didn't die"; >>> >>> The code above when run would echo "A test. We didn't die."; >>> >>> >>> >> Whats about >> >> $user =3D $this->getUser(); // Throws exception >> echo $user->getName(); >> >> >> Now the second one will fail too, but in reality it shouldn't even get >> executed... >> >> Regards, >> Sebastian >> >> > > Then the error handler shouldn't have called resume. =A0The error > handler should only call the keyword if its safe to do so. =A0And now > that I think about it, not having the ability to return anything would > be for the best since it would keep the usefulness of this to a > minimum and avoid magic headaches. > > Cause the last thing we need is for people to start using the > exception handling mechanism as additional control structure tree. > > What about what I'd mentioned before that this would allow? =A0With this > in place the existing PHP Errors could all be converted to Exceptions. > =A0The default exception handler would resume after catching any low > level exceptions (E_NOTICE, E_WARNING, etc) but a custom one can be > free to do whatever. > > Unifying the mechanisms also would allow for exceptions for other > fatal events. =A0This would be highly useful. > > try { > =A0require( 'path/to/file.php' ); > } catch ( PARSE_EXCEPTION $e ) { > =A0// some logging then pretty death > } > > Most of the time you'd never want to resume after such an > exception.... Most of the time. > > In any event "resume" would allow PHP to get back to having only one > exception mechanism instead of two since the behavior of errors could > be emulated under exceptions. That is the principle boon of resume. > > Does that balance the two drawbacks > 1) It's a new keyword, so BC breaks occur with code that used it as a > function name. > 2) The spaghetti possibilities increase. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com