Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69334 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80353 invoked from network); 25 Sep 2013 08:59:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Sep 2013 08:59:13 -0000 Authentication-Results: pb1.pair.com header.from=terence.copestake@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=terence.copestake@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.182 as permitted sender) X-PHP-List-Original-Sender: terence.copestake@gmail.com X-Host-Fingerprint: 209.85.216.182 mail-qc0-f182.google.com Received: from [209.85.216.182] ([209.85.216.182:61859] helo=mail-qc0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/20-14049-0E5A2425 for ; Wed, 25 Sep 2013 04:59:12 -0400 Received: by mail-qc0-f182.google.com with SMTP id n4so3958350qcx.13 for ; Wed, 25 Sep 2013 01:59:10 -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=QiRTzJhj+sggryr3k5p4Ez9N9F508QzN2FeR+lmiQoQ=; b=Y+GRdGWycfsHXbALD9ErB4dQBrktOHNfLz2aT0uFJeMYzEHGR7fp07Z4oaYQNLCzEs ++B70BfuhienKjelHKe/t4pS5EO0AKG+M8w4CiisSgoUtg7Ojtcxvr930o9NvVp2nmBX CUrUbmYNjsSzoUQSKjKvrJ9GmeCLB/Sk0uoUGuQMwHBItfgN9yKF9e1zuM9N9+WLDi7M UTX7k+VzOikXbX0CcyLkdYWBLQQfQecScciCEDX4M51DgdCPpSZn3ZtFbVlSuEGJRzWY cu7L7K9RfKep1uMdw/gpLUQ7hY2aG3CrH6L8LPq8PhuLWfsdBOU5b+u0O6IiG40b27Ke A1eA== MIME-Version: 1.0 X-Received: by 10.49.1.42 with SMTP id 10mr726202qej.58.1380099550099; Wed, 25 Sep 2013 01:59:10 -0700 (PDT) Received: by 10.140.90.69 with HTTP; Wed, 25 Sep 2013 01:59:10 -0700 (PDT) In-Reply-To: <524205D8.8000608@php.net> References: <5241F11C.5080707@php.net> <008301ceb967$b49ab190$1dd014b0$@tutteli.ch> <524205D8.8000608@php.net> Date: Wed, 25 Sep 2013 09:59:10 +0100 Message-ID: To: Joe Watkins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b677e58703f9f04e7317774 Subject: Re: [PHP-DEV] RFC: Anonymous Classes From: terence.copestake@gmail.com (Terence Copestake) --047d7b677e58703f9f04e7317774 Content-Type: text/plain; charset=ISO-8859-1 I'm growing to like the idea myself. It may create new opportunities for bad practices, but I don't think it's the concern of internals to police how people may or may not use a feature. There are also I think a few things that would need to be addressed before this would be ready for the real world. For example: 1) As hinted at previously, the "use" statement. Doing this per-method as suggested would be less ambiguous than applying to the whole class - and would also prevent pollution. 2) Transparency between an anonymous class and the class in which it is defined (if any). One thing I found very restrictive about closures back in 5.3 was the lack of $this support. I can imagine that missing functionality being similarly restrictive for these new anonymous classes. Obviously $this itself will be reserved for use by the anonymous class, which means there would need to be an alternative. Passing in a variable is one thing, but as it stands the anon class would then only have public access. Something like $class with similar behaviour to $this could be an option. In Java I believe anonymous classes have the same scope as the method in which they're defined. Would something like this or similar be feasible and permissible in PHP? --047d7b677e58703f9f04e7317774--