Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97488 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33141 invoked from network); 29 Dec 2016 16:59:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Dec 2016 16:59:50 -0000 Authentication-Results: pb1.pair.com header.from=nicolas.grekas@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nicolas.grekas@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.194 as permitted sender) X-PHP-List-Original-Sender: nicolas.grekas@gmail.com X-Host-Fingerprint: 209.85.223.194 mail-io0-f194.google.com Received: from [209.85.223.194] ([209.85.223.194:34289] helo=mail-io0-f194.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/F5-04761-50145685 for ; Thu, 29 Dec 2016 11:59:49 -0500 Received: by mail-io0-f194.google.com with SMTP id n85so19877992ioi.1 for ; Thu, 29 Dec 2016 08:59:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=v12L0vgXpUDsWrSjlsxP+N7nvhefBt/pSe1vsZXVkFA=; b=dyzYfun415jv1zIpRTfRCVMg6vN+sI6FoPse2WfXkSmTvvhN/blLa/bdz/iKR6YhB6 mlDUC38n+oMQsZXZjKb0Ni5piOexVkNYlh/ttXfPwogxihWjg2AIXHRBzw5p7QW2vWYs 2KWZ3+caHg61opXQqmGVoglHVOIsDJgeaYxHQg8cpIFGr+cFT85CTDOMGRYtjkQ8vUDG mLP8JLauYt56FK2Gmk2UnFkXiP6jXD0xyY+CTs0SuQ8gd5l7B4FVQmmYraM5v7Lzb0KD 94nY17CdZUfo3+xtuGzXwuvfphBrmNRpRSzsPhZavKUd3AsGXVMpanytmCzQEb0/dETg 2OlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=v12L0vgXpUDsWrSjlsxP+N7nvhefBt/pSe1vsZXVkFA=; b=CYCN/70FfQSJMW9NytNfu1PQB1KmRwwYzo+QNsPWf7Ab7qWT3Ufl5QjcdF+fvPo+BG +fHcEfbIvbqzS+6HIV+oo9BPt7lndEar6CmDvWv1cbg0Uc802rUPrgqsOj8l277qOnmV MD6U0/gWMsXJWh9Nhrt0M0Jvca4CbshRQVqD3vA4EbRcHk4lNHl+P8wNCJj/xPmaw58Z rKmAeFFbZrxcasuoEdFlrku9sJUd9TPLXMQKRzvxg+srZR93uInoyBHYMajywImxRsEl i1CYJ2c8Dvaw3AeMRWnWoMvWSvhvvESBlfmmHbPLMTB76qudtnKjE84fn6SHZ4rUR4FJ qx3Q== X-Gm-Message-State: AIkVDXL574p2rQLHG7wAipZkxWW9dCDPScIJrXVYqAVjnTCgbp0FPyTzWb/AyPn3z34bF++XNrEyYPgZ69Iz3w== X-Received: by 10.107.55.136 with SMTP id e130mr29824231ioa.76.1483030786940; Thu, 29 Dec 2016 08:59:46 -0800 (PST) MIME-Version: 1.0 Sender: nicolas.grekas@gmail.com Received: by 10.107.48.6 with HTTP; Thu, 29 Dec 2016 08:59:26 -0800 (PST) In-Reply-To: References: Date: Thu, 29 Dec 2016 17:59:26 +0100 X-Google-Sender-Auth: KWSeajeR1DHRX3ODR8Fm0kKkTq4 Message-ID: To: Nikita Popov Cc: Joe Watkins , PHP internals Content-Type: multipart/alternative; boundary=001a114ac2803f32000544cf035f Subject: Re: [PHP-DEV] RFC: Anonymous Class Lexical Scope From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --001a114ac2803f32000544cf035f Content-Type: text/plain; charset=UTF-8 Hi everyone, having worked a bit with anonymous classes these days, the current boilerplate is really high to inject some local context into them. So big +1 from me for the target. On the proposed syntax, I really prefer Nikita's proposal: return new class { > private $a = $var; > private $b = $obj->prop; > private $d = $obj->prop ?? 'default'; > // ... > } > The "functional equivalent" wording in the RFC has a big drawback: it looks like the parent constructor is overridden, which would be a really nasty side effect. It may not be the case in the implementation, but the the RFC needs to be clarified IMHO. If we were to need more closure-like syntax, we may even use "use" like this: return new class use ($var, $obj) { private $a = $var; private $b = $obj->prop; private $d = $obj->prop ?? 'default'; // ... } I really hope this new syntax (which ever raises the consensus) can be ready soon :) Nicolas --001a114ac2803f32000544cf035f--