Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69262 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92193 invoked from network); 23 Sep 2013 08:48:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2013 08:48:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.53 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:56611] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/C0-22780-A6000425 for ; Mon, 23 Sep 2013 04:48:43 -0400 Received: by mail-qa0-f53.google.com with SMTP id k4so1274045qaq.5 for ; Mon, 23 Sep 2013 01:48:40 -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=S2qFhemVUFjyEEYpRh2vrC2Z1jv4tU8yfezyd7N/jEg=; b=U0U2OoLCuelSzFD4Kq+U4oj20lyioSiJCWRhKU2GidH5VBVf+XNzcQpODsL0vbKp97 hmdgpShx/+crOEnQiWEkUAcQKszzWy5F6SCpn7xbnHI659abcLcLLZ4l5Hv+5xSSqaYh 0tfdqdyleLWEEZSzZfRt1/1Q5aFCDrSR/yIAzsp43jrB5iDi4ihOv8nzG19mfUXzNga2 nNJ/jP9yV3FN1FtV8zkzxZpLtb6q36Yr/IcRuRxpo2YClt0miz/opNsu1BT1vidmR/XR oKCJ4G/Y3sCJFidVwNW/n9NQdR1ZXEPVjDglJXrIV7UWBQaHB0S8HItlca8ioa//+9P2 yg7g== X-Received: by 10.49.1.9 with SMTP id 9mr21056153qei.51.1379926120351; Mon, 23 Sep 2013 01:48:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.23.176 with HTTP; Mon, 23 Sep 2013 01:48:20 -0700 (PDT) In-Reply-To: References: <523FFE44.8030107@lerdorf.com> Date: Mon, 23 Sep 2013 10:48:20 +0200 Message-ID: To: Sebastian Krebs Cc: Rasmus Lerdorf , Joe Watkins , PHP internals list Content-Type: multipart/alternative; boundary=047d7b5d4e5e38522104e7091674 Subject: Re: [PHP-DEV] RFC: Anonymous Classes From: ocramius@gmail.com (Marco Pivetta) --047d7b5d4e5e38522104e7091674 Content-Type: text/plain; charset=UTF-8 On 23 September 2013 10:44, Sebastian Krebs wrote: > 2013/9/23 Rasmus Lerdorf > > > On 09/22/2013 11:39 PM, Joe Watkins wrote: > > > https://wiki.php.net/rfc/anonymous_classes > > > > > > I'd like to hear thoughts regarding the addition of anonymous > > > classes, patch included. > > > > I am having a hard time picturing a real-world use-case for this. > > > > The use case is one-time usage of an "implementation", where you currently > probably pass callbacks into a "Callback*"-class like > > $x = new CallbackFoo(function() { > /* do something */ > }); > > vs. > > $x = new Foo () { > public function doSometing() > { > /* do something */ > } > }); > > Imagine you have several abstract methods in one interface/class, which > would need several callbacks passed to the constructor. > Also '$this' is mapped to the right objects. > > Regards, > Sebastian > > It also avoids usage of these classes outside the scope where they are defined... I'm not sure that I like it yet, since the only use cases so far are very weird edge cases in my strange experiments. Surely needs stronger use cases first... Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --047d7b5d4e5e38522104e7091674--