Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83686 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34290 invoked from network); 24 Feb 2015 19:22:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 19:22:45 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.182 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.182 mail-pd0-f182.google.com Received: from [209.85.192.182] ([209.85.192.182:37592] helo=mail-pd0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/B1-24698-38FCCE45 for ; Tue, 24 Feb 2015 14:22:43 -0500 Received: by pdbfl12 with SMTP id fl12so35490992pdb.4 for ; Tue, 24 Feb 2015 11:22:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=CQk1oCe/MjpywJH6a18EG4GJxEKRdxSMyV0LC6n/SYs=; b=oLPTxfnHftELjzygX19cTkJc0U7YuaC847qUbAU/tw+qvOxRvfVpk75FlVbOQJL6Lt 1D+t4EsCQu/TyBlyKn3qlLEbq4BwDpI29qDsDESF2KVc+2E4giSPMJHRQXGftZRmE0F1 M7rWfGrsS0un0qtEPKhyK155hf0/1pxgFoI7JsEpvsYn+RuryV/5Y6dCFstfbkiQ8wpH L0MmXjvqSghmeDLJvgwfm8Ut1tqqKSJLjcebYZTo/8GAW32nniMSz8ByzN8lrlWg0QJs IsKsJOIoGUxf5ONSXdKK5kmfL8NAudBOAG8VsJaz+UUBDn9ZzNwp+cI72PC+snyHVloI zomw== X-Received: by 10.68.135.166 with SMTP id pt6mr6144605pbb.74.1424805760512; Tue, 24 Feb 2015 11:22:40 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id dc4sm17852758pbb.55.2015.02.24.11.22.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 11:22:39 -0800 (PST) Message-ID: <54ECCF7C.10901@gmail.com> Date: Tue, 24 Feb 2015 11:22:36 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Philip Sturgeon , PHP Internals References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > https://wiki.php.net/rfc/anonymous_classes > > There's a little RFC + patch that Joe Watkins put together, and as > before with the ArrayOf RFC, I'll be helping out. > > So, lets get this discussion rolling. This is a nice and clear proposal, however I'm not sure I'm completely convinced about the necessity of it. In Java this kind of pattern is used very frequently, because Java is a statically typed language where it is the only way to achieve dynamic interface, and has other capabilities, see below. In PHP, there are other ways (and can be made more ways, such as more support for duck typing). Also, the question arises when comparing this to Java - would anonymous class functions be closures connected to the environment? In Java, they are and that is what they are most frequently used for - to make contextualized callbacks. In PHP, you need special syntax to capture the environment, so how that would work? Also, what about scope access, etc.? > Sadly due to the way in which people have had ONE CLASS ONE FILE > drilled into their head since PEAR and continuing through Zend and > PSR-0, it can become a PITA to add some simple functionality if a > small class is needed for one tiny thing. One class/one file may be a good idea in general for a big project, but as they say, any feature that can not be turned off when needed is a bug. -- Stas Malyshev smalyshev@gmail.com