Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69336 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93350 invoked from network); 25 Sep 2013 13:02:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Sep 2013 13:02:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=terence.copestake@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=terence.copestake@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: terence.copestake@gmail.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:45872] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/00-27377-CFED2425 for ; Wed, 25 Sep 2013 09:02:53 -0400 Received: by mail-qa0-f53.google.com with SMTP id k4so3394637qaq.19 for ; Wed, 25 Sep 2013 06:02:49 -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=nZRN+BtmQxNQjnPbs4QqkcWQzfmGpKw6EoN1jpE4+zw=; b=OujoiFjuW1eB5GZNmdk9ZWf6+wWQN8CCr6RVmAQ4JNAKL7VBsTXTtTZIdQ8NjWEqIf kjBBp6Lgsa7fM+PdeUc8+7alAxkeoPib//XOxTEcUaz+lOIftw+7mSkr8f/H1NMr/FRT frUhgqBYixrylvllBM1ZOt9SUILfQyRHQccgQ0gvVx3PFEIQw3EU5LIVvThbfBLpQqoy Yc3SfuklGV5zPe6aiWxtXXcOp++uL2fGvo+Tt4YYq04/PUszfLp104bUalUo8uOV3DdX eGcoV2xZqMs/qjeLHNQcBxIPjw2WAG3y7lp2ErZlHS+chLU6SZtZ5D0/9vadscJiis4u QPgg== MIME-Version: 1.0 X-Received: by 10.49.1.42 with SMTP id 10mr2013217qej.58.1380114169784; Wed, 25 Sep 2013 06:02:49 -0700 (PDT) Received: by 10.140.90.69 with HTTP; Wed, 25 Sep 2013 06:02:49 -0700 (PDT) In-Reply-To: <5242ADAE.2080007@php.net> References: <5241F11C.5080707@php.net> <008301ceb967$b49ab190$1dd014b0$@tutteli.ch> <524205D8.8000608@php.net> <5242ADAE.2080007@php.net> Date: Wed, 25 Sep 2013 14:02:49 +0100 Message-ID: To: Joe Watkins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b677e58d6f1d804e734def2 Subject: Re: [PHP-DEV] RFC: Anonymous Classes From: terence.copestake@gmail.com (Terence Copestake) --047d7b677e58d6f1d804e734def2 Content-Type: text/plain; charset=ISO-8859-1 > 1) Anonymous classes in PHP would support a constructor, so I don't see > the need for use to be utilized here, it would just clutter declarations > and the patch. This works, but it's more effort for the programmer and arguably just moving the "clutter" from the declaration to the constructor. e.g. (new class ... protected $value; public function __construct($value) { $this->value = $value; } public function doSomething() { echo $this->value; })($val) vs. (new class ... public function doSomething() use ($val) { echo $val; }) It gets even uglier for passing by reference. > 2) Again, constructors can be used, and is less confusing than introducing > a new variable, but I'm open to persuasion if the idea is liked in general > ... This is fine when working with only a handful of values, but what about needing access to a large number of values? What about making (especially protected) method calls within the anon class? Along the same vein, why did we even bother having "use" and $this for closures, if you can after all just pass everything as arguments? If there are realistic and elegant alternative solutions to the problems presented, that's fair enough. Rejecting something because it's not as simple to implement and you can hack around it in user code anyway... that's a dangerous way to go about your business. --047d7b677e58d6f1d804e734def2--