Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67803 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98927 invoked from network); 25 Jun 2013 11:52:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2013 11:52:29 -0000 Authentication-Results: pb1.pair.com header.from=g.b.yahav@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=g.b.yahav@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.51 as permitted sender) X-PHP-List-Original-Sender: g.b.yahav@gmail.com X-Host-Fingerprint: 209.85.220.51 mail-pa0-f51.google.com Received: from [209.85.220.51] ([209.85.220.51:57034] helo=mail-pa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/E9-49518-B7489C15 for ; Tue, 25 Jun 2013 07:52:28 -0400 Received: by mail-pa0-f51.google.com with SMTP id lf11so12480853pab.10 for ; Tue, 25 Jun 2013 04:52:25 -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 :cc:content-type; bh=JaZINJBqX96nyhp9MV3Xn/8d4tTThAh+ir5v+C7LWxE=; b=ETqB4xyc0M7MV440gDgU00u88/e/7/lWjEBwPzbAFcl0nR1baZuZfETKmvvbCrqbUu RRJ98cdwOOaxZwP/S4ZWsKwXOlKlxN3i5YnHlBxxFsC7xZmWA4UN94kf0MscRJu4Qlaf 5n7yFCN2BkNIfdbTZ/Y3OpxUefKfC5jIKRyjY6jys7vpXYFo3V+77E/IUZol5OZsWIzb aMZvoUYkIskMcgGyy+8lXlZCP5cz0ht8AP09PYqSWpQMJelLdg2DzswjEf0PB0w+tjuQ 61tkJY/3W+jIs/gi0p1L8EjkKpNPOSnriggMIMVAFje1jq83TFqKsf/6NUJUS4D9uvqK Ortg== X-Received: by 10.66.91.107 with SMTP id cd11mr31739654pab.74.1372161145087; Tue, 25 Jun 2013 04:52:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.70.92.132 with HTTP; Tue, 25 Jun 2013 04:52:05 -0700 (PDT) In-Reply-To: References: <4ED7146272E04A47B986ED49E771E347BB4DF6F235@Ikarus.ameusgmbh.intern> Date: Tue, 25 Jun 2013 14:52:05 +0300 Message-ID: To: Joost Koehoorn Cc: Christian Stoller , PHP internals Content-Type: multipart/alternative; boundary=0023547c8a91a0b6d904dff92982 Subject: Re: [PHP-DEV] RE: Announcing RFC 'Anonymous Catches' From: g.b.yahav@gmail.com (Yahav Gindi Bar) --0023547c8a91a0b6d904dff92982 Content-Type: text/plain; charset=ISO-8859-1 I, too, believes that omitting the exception variable is great. In addition, anonymous catch blocks will shorten the code of "catch (Exception $e)" so... is just a simpler way of writing - and that's what PHP agenda aiming for, doesn't it? be a friendly and readable language. Reading try { $foo->bar(); } catch { show404Page(); } For example, is readable, short and not contain any extra variables that we didn't used. On Tue, Jun 25, 2013 at 2:18 PM, Joost Koehoorn wrote: > > Hi all, > > > > I just published an RFC that proposes to add catch-statement without > needing to specify a variable, and support for fully > anonymous catches. > > > > Details can be found at: > > > > https://wiki.php.net/rfc/anonymous_catch > > > > Regards, > > > > Joost Koehoorn > > > > Hi. > I am not sure about complete anonymous catch statement (like try { } catch > { }), but I really like the proposal for omitting the exception variable. > > Because in frameworks like Symfony there are defined and used a lot of > special exception types for each cases. > Here's an example that shows what I mean: > > try { > $foo->authenticate($user); > } catch (BadCredentialsException) { > echo "Bad credentials"; > } catch (InactiveAccount) { > echo "Sorry, your account is not active anymore."; > } catch (CurlErrorOnAuthService) { > echo "Please try again later, the login service is currently > unavailable."; > } catch (Exception) { > echo "bla blubb"; > } > > In such a case you do not need any `$e`variable. Netbeans for example > always highlight's these variables because it is not used anywhere. But I > think it looks a bit cleaner if the variable could be omitted, if it's not > needed ;-) > > Best regards > Christian > This is exactly the reason, yes! > > As stated in the RFC, I think it's best that we consider the two ways > separately. Omitting the variable is a much smaller change (and requires > very little code changes) than having a fully anonymous catch. > > I originally dived into this because of a question of Phil Sturgeon on > twitter, requesting for making the variable optional. I took it one step > further and made the whole thing optional, but surely we can decide to only > make the variable optional, I can see how it's bad programming practice to > have fully anonymous blocks (even though sometimes they may be used). Just > throwing this out here to see what you think about it. > > > > Regards, > > Joost > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0023547c8a91a0b6d904dff92982--