Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107063 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57129 invoked from network); 13 Sep 2019 11:28:22 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 13 Sep 2019 11:28:22 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id B1D112D2006 for ; Fri, 13 Sep 2019 02:04:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Fri, 13 Sep 2019 02:04:28 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id w10so1874015plq.5 for ; Fri, 13 Sep 2019 02:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=OZs9p4ZBtxRJ2FJ3kyU213hKDEAtMCleGy1aEBxTZmU=; b=FaILVn/8yowuJJGfgD61BBVXAS+IbPgMF06EYj3BiFj88Tm5a27SwqFa3be3xHi7xX 9Yau4G267nyjVdsHlKPe2VZeIaeL6DJuJYn9K1Czc6htKamhuHRioIhLKncAjY+iZPZY CIFrRHfvtm7mzjIy4eayx6K9JlrBJPqx23KA564XjN5ErZh+VYbEXxLRj3/19oqVnOEt GFXazjs0Si62iZ5iuKoLuFf/+L1hRZXTwooo2IIPc8SuMW2I3pskSJMRvo6T4GXLeaPQ 1egRcyYB4+fQjEYG3xQaKb/xuEQ52RqjARWjVnRIJ740xTI6cjiaLrARVffgxi3Krd+e NERQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=OZs9p4ZBtxRJ2FJ3kyU213hKDEAtMCleGy1aEBxTZmU=; b=mARsrinZTGDf6n42UuoFoVgyF/K7nEkcZz48JMYCg5YanEpzns4IEa0ryh4udNuBpW nj4DAMfraYkwCwdB2+DwrzBZa2DcXvcDXPjpPqfzvNi6u/W4AQq+hkVgGxaLWsgWu7G8 dxWCG0uGY7dFhPIOc9VAURZti/R+htEnK/oNvLP6aVRZJ2QGPSaNrGGF8gA5r99hrP9c qG3Vo+tVqmbVGRvZLWoArxpSrwTicJ+K+zktluoRPYMacqOC7Dhthi1dZNK4A8XT6Brn j72PEG181IXmEUR0hR8c+LXlOxnhrfb3KfKpkHfPQtQn2pwMg3889SXjV1SP9BlvhwXg A7Xw== X-Gm-Message-State: APjAAAVpuWhp8catqZBKk39N0SgGjHHemwD49XPtP/2LYYFRD8GpdeKO atDfB7DWVTj//5E50PSupybIlA== X-Google-Smtp-Source: APXvYqyLSuYTWIHtQwu7R8cdHW7Rpsj7PpcnTZXA8ipCcxhVLjz9wIV8mmfDURIJKOlp9A7rJrWIbg== X-Received: by 2002:a17:902:a40a:: with SMTP id p10mr40282495plq.108.1568365467229; Fri, 13 Sep 2019 02:04:27 -0700 (PDT) Received: from [192.168.202.38] (50-252-183-45-static.hfc.comcastbusiness.net. [50.252.183.45]) by smtp.gmail.com with ESMTPSA id v8sm3508687pje.6.2019.09.13.02.04.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 02:04:26 -0700 (PDT) Message-ID: <2CA1F9C5-AC54-4E45-AE9E-20BB32BD7093@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_0F1484F2-5079-44EA-95C7-3C410090E439" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Fri, 13 Sep 2019 02:04:25 -0700 In-Reply-To: Cc: PHP Internals To: Arnold Daniels , =?utf-8?Q?Micha=C5=82_Brzuchalski?= References: <74C03BB1-28DF-4694-A91D-2516C545F8B2@gmail.com> <3CA484B0-BCA3-4A2B-B2A6-8B845F9C462B@newclarity.net> X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Object Initializer From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_0F1484F2-5079-44EA-95C7-3C410090E439 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Arnold, > This can easily be done in a number of ways, like the suggested helper > function. A helper function can simulate an object initializer but it cannot = provide the same potential benefits.=20 The helper function uses array keys to identify properties, and as array = keys cannot be declared like class properties, neither IDE, tools, nor = PHP itself can validate the names and types of those keys like they = could if object initializers were used instead. Michal, > I don't like how it works for anonymous classes. It's more difficult = to > implement since the compiler doesn't know the meaning of the (first) > bracket. It's doesn't make the code more readable, for the same = reason. I > think it's better to not support this syntax with anonymous classes. >=20 > The examples do not show how constructor arguments are passed. I'm = assuming > it's >=20 > $customer =3D new Customer("foo") { > name =3D "John" > }; >=20 > About the idea of letting `{ foo =3D 10 }` create an `stdClass` object = (not > in the RFC); While not used much since it has no effect, it's = perfectly > okay to put your code in brackets eg `{ { { $foo =3D 10; } } }`. As = such, I > don't think it's a good idea to allow `new stdClass` to be omitted. I am curious why your RFC uses "=3D" instead of "=3D>" for separating = properties from values? =20 If we used "=3D>" it is potential =E2=80=94 with lookahead parsing =E2=80=94= that the following could be unambiguous: { foo =3D> 10 } -Mike= --Apple-Mail=_0F1484F2-5079-44EA-95C7-3C410090E439--