Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92473 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92126 invoked from network); 19 Apr 2016 16:02:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2016 16:02:07 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:37419] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/80-22821-D7656175 for ; Tue, 19 Apr 2016 12:02:06 -0400 Received: by mail-wm0-f49.google.com with SMTP id n3so37903855wmn.0 for ; Tue, 19 Apr 2016 09:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=FC447NN0lx1igSSO1G5BjEg/1h4pUX5ByzjVx/xJLAs=; b=laUPERCrRfVPQr58IVZmdmiy4E3CC2cIf0xvoU0ikWCuzokQuedkjUiIOvvEarWQ1N PtzC3LPjWNIB4Vu9EY5C7t+5+xrAvBeKDBWuN6qi+BoV+4HhAGFmVfApKtAfd+k4Ycni lfJrIB7gSRLVRWBnRRe2zZUhS9tIzM3FB0AanhjYmcK6pJ3J8Q0UPI7caS+pUrfYZlTY l1teZVIG8xpLgm7VtAtmBoUOlfK4hZWvGfN0f4t4esazRTzgNIDEesaxuGC0b9QecUy+ H1p0Kdlq4gtsVaqApmH2SIRbp5A5B374kaWjHIs0oq3TdK5dBeSGlbHoaEBbdikYBr1e 294Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=FC447NN0lx1igSSO1G5BjEg/1h4pUX5ByzjVx/xJLAs=; b=h5z724vgRx33C6rCXpGE9aDo6+hVo6RBRuSLVGfc6szhcz7bruPMpHxvsiibAFrIFD GwqwYBP3zQN2wm/Rm/33yFcTZznbAPZ0G08sIgMyFN84VFfiqtbDlsZdDFEapkVz23gK e8Ahus7SpVd9+ePvBhbOhZEauiSEo9UaJM9Cje85TJ3Y+6HGW6yxYuynOyzLPW5rkDSt 7meoHkT3KZEsN7euCyWAIwT/S1oyBeW3XFnsykAtK3sAKS4LgGFFoTWcBl3DRkP0IUIM D+7t/rY9wcCV70x63Ay4SvmGmmh5GkOHHcHvJ+B9n29pLbIM6qCAuouMelKhKPIbq1kZ 85vg== X-Gm-Message-State: AOPr4FXiyYCELk4BgvHpHx0sVIS5nooxVp6iNxCjlcBlLHnUShnDFIdzdpDsxYI2JUVT5A== X-Received: by 10.194.190.201 with SMTP id gs9mr4488511wjc.133.1461081722119; Tue, 19 Apr 2016 09:02:02 -0700 (PDT) Received: from [192.168.0.77] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id a1sm928342wje.43.2016.04.19.09.02.01 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Apr 2016 09:02:01 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <5716561C.3020600@gmail.com> Date: Tue, 19 Apr 2016 17:00:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Anonymous Class Lexical Scope From: rowan.collins@gmail.com (Rowan Collins) Hi Nikita, I was thinking some more about your suggestion: Nikita Popov wrote on 19/04/2016 15:18: > $foo = 42; > return new class { > private $bar = $foo; > public function getBar() { return $this->bar; } > } If we allowed this, would it make sense to also allow it in named classes? This is currently illegal [https://3v4l.org/Kp0ep]: $foo = 42; class X { private $bar = $foo; public function getBar() { return $this->bar; } } > It probably doesn't make sense to > restrict this to specific expressions, so all of > > return new class { > private $a = $var; > private $b = $obj->prop; > private $d = $obj->prop ?? 'default'; > // ... > } > > could be fine. We don't allow importing expressions into closures, nor are any of those property initialisations valid in the definitions of named classes, so I think allowing them here would be odd. Regards, -- Rowan Collins [IMSoP]