Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69314 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97085 invoked from network); 24 Sep 2013 12:30:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2013 12:30:11 -0000 Authentication-Results: pb1.pair.com header.from=kristopherwilson@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kristopherwilson@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: kristopherwilson@gmail.com X-Host-Fingerprint: 209.85.223.170 mail-ie0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:47529] helo=mail-ie0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/61-24892-2D581425 for ; Tue, 24 Sep 2013 08:30:11 -0400 Received: by mail-ie0-f170.google.com with SMTP id x13so8985578ief.15 for ; Tue, 24 Sep 2013 05:30:08 -0700 (PDT) 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=xkjvg4kykTFabItooFj0TeEw2RpZgN+jaNXyngkrZTo=; b=IMBy1wj+kXvEtmruPKlFMfAHlVAMSlDtUIBoHbpoqHezYfncWOO/xz/Nut9nd11dg+ hjoo2lSUe6cDbFmS4nrGzohzD0P35vH3uHIMDJh/47UA+JtUjBzH6kU1fHL7BbnbHERC rFPPlZ/ufsZk/pficiDg6W+XZtD4C3SPEE/XtV/p+mwcDx3T3LxA0tBr6cf3bSNXgcGJ 8GJ+zjOt7ZvhMdxmJiDDuZcHCKH7Er3MD0TxeiBj2QY50WY0PC2axkFumKM4sFa5vZHS 2MYX90IhnCQLw28ATVokr5RlveAWuu+CDyDJodVHIHmItsXhqrfFr7xYeAPCENOstCq9 /tCA== MIME-Version: 1.0 X-Received: by 10.42.223.134 with SMTP id ik6mr21228375icb.4.1380025807238; Tue, 24 Sep 2013 05:30:07 -0700 (PDT) Received: by 10.64.240.225 with HTTP; Tue, 24 Sep 2013 05:30:07 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Sep 2013 08:30:07 -0400 Message-ID: To: Terence Copestake Cc: David Soria Parra , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11330a16057eb004e7204cd4 Subject: Re: [PHP-DEV] RFC: Anonymous Classes From: kristopherwilson@gmail.com (Kristopher) --001a11330a16057eb004e7204cd4 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Sep 24, 2013 at 8:25 AM, Terence Copestake < terence.copestake@gmail.com> wrote: > Playing devil's advocate here, could this feature make the language more > expressive? > > Take for example an API where you'd typically wrap a method call in > try/catch blocks to handle the various "outcomes" e.g. a user login, you'd > maybe have a UserDisabled exception, a UserAlreadyLoggedIn exception, a > UserPasswordIncorrect exception, etc. > > With the addition of this syntactic sugar, the method could instead accept > an anonymous class with a onDisabled, onLoggedIn, onPasswordIncorrect > methods. > > Perhaps it would also have a performance benefit over cascading through > catch blocks? Though someone else would have to confirm that. > Why wouldn't you want this to a concrete, real class? I don't see the benefit, in your example, of doing an anonymous class vs defining an actual class and passing that in as the handler. --001a11330a16057eb004e7204cd4--