Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109447 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13903 invoked from network); 30 Mar 2020 09:51:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Mar 2020 09:51:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8FE951804E2 for ; Mon, 30 Mar 2020 01:17:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 30 Mar 2020 01:17:21 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id j17so13343763lfe.7 for ; Mon, 30 Mar 2020 01:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0RgGAZDpMzV5J7Osj7Re9RWX6zeNilcYONNZ+cS7Qsc=; b=KuaGyiS/zQS1kWMhNKS8LraEbLgeFHl6GhdL+ZFmnBBaOT5NTiWt+Bji5HrGqDmXdk zX4DLv10lp7PPpVsLr3GQLJEchzU3xkiif1gpyHYUNrMZBq1vzyEafWEKC982aMoLqee IZ80AGxeTzrz/WFuA4Vtt8MITFM/roh9jKlkdz5KFbQLcZOSbkPV0JLiczvvEU3JJcXb ckgh6jyZFCYW4EhQ6Kn3bdXKHaw/8Y7sHrgEYmyGGM5QuU0Ui6typQPJ0VLkWCXUe+iA a2FdT6PxRpgAEkliDT8eoFJnSRu1G3GOVbk8phZyLvOEYUKU3N5pAXGMp5w5mGKTts9Y Psnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0RgGAZDpMzV5J7Osj7Re9RWX6zeNilcYONNZ+cS7Qsc=; b=Yn+UApBhH17wt/MnWin72uhfL7VM/wBqLiz9JnvLk/Q+s8+KMhY5kMKbtOQ/WOmUpo p3P3LnprS26OUCv448LaaAr4FfPKp2HpW66G0YbozvfdD0LlRkVV7IjiaNvqoS2MUK5S fN5y63tvhLgtyO1BkjgESGpoR/yseMBEnkBy23dp265bpsXtAvNBqjgM4FoVejxhdnnI ihM3SfAjgbeQjYQ7q9hLVvMFaiitNLOf+3ET2ejhqbQ4bRhAIYE7fMmPTmBveK5q6yPs fJrCSYF95etfSHBYX1Mh+EcTXQGEUY0qgL0ua0+6hm+z87iyoPcnkfoNvvao4k9zLYiH +1Lw== X-Gm-Message-State: AGi0PuYraw+xoujrJ7iiJJYQOy/hm6IPTOEmRtuPlweSSVDf2BDgNEn1 t0fjpceb2dkxaQ9bZ/GnV53BXW9AID454s7/tu4= X-Google-Smtp-Source: APiQypK9zVHDuxote4bgpqsTE0/leNp51c0JKCbRuk1Tv+Uy7yPTfG03amGzFZr0DZM/hJ17+JGpG1leReLRvh27eSA= X-Received: by 2002:a05:6512:200a:: with SMTP id a10mr3348455lfb.154.1585556238059; Mon, 30 Mar 2020 01:17:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 30 Mar 2020 10:17:01 +0200 Message-ID: To: Levi Morrison Cc: Jakob Givoni , php internals Content-Type: multipart/alternative; boundary="0000000000005756f205a20e14db" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment From: nikita.ppv@gmail.com (Nikita Popov) --0000000000005756f205a20e14db Content-Type: text/plain; charset="UTF-8" On Mon, Mar 30, 2020 at 3:06 AM Levi Morrison via internals < internals@lists.php.net> wrote: > The current RFC text is not consistent with using `=` or `=>` for the > assignments. The assignment `=` is vastly more common, though, and I > don't understand why if we are using an array syntax we aren't using > `=>`. > > I intend to vote no. I agree that we need to do something in this > space, but this is not it. I don't want perfect to be the enemy of > good either, but I think this still needs more work. Maybe interested > parties (including me) can collaborate off-list somewhere? > This is going to be a "no" vote from me as well. I don't think it's really possible to "save" this proposal though, at least if it remains as syntax sugar to perform multiple property assignments to one object. The syntax has two use-cases: Object initialization and everything else. I don't think it's doing a good job at solving object initialization, for reasons that others (and in particular Larry) have already pointed out in detail. And I don't really see a use case for this kind of mass property assignment outside of object initialization. I don't have much of a problem with the limitation to public properties (I love public properties!), the problem why this is unsuitable for object initialization is more that it is in practice mutually exclusive with constructors. You can either have a class that defines a constructor, in which case you can't use COPA with it (as the constructor would be doing the initialization -- ignore the argument-less case here), or you have a class without a constructor, in which case you essentially must use COPA. There's also no migration pathway between these two modes, in that switching between them is a backwards compatibility break for library consumers. And if it turns out that an object needs non-trivial construction logic at a later time, you can not easily introduce it without breaking COPA style initialization. This problem is not really limited to this proposal, it's a general problem of retrofitting object initialization syntax to a language that traditionally did not have it, and it doesn't seem to be an easy problem to solve. Regards, Nikita --0000000000005756f205a20e14db--