Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109106 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89093 invoked from network); 17 Mar 2020 17:29:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Mar 2020 17:29:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB34D18054A for ; Tue, 17 Mar 2020 08:52:20 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 ; Tue, 17 Mar 2020 08:52:20 -0700 (PDT) Received: by mail-ot1-f44.google.com with SMTP id s15so22146326otq.8 for ; Tue, 17 Mar 2020 08:52:20 -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=ZTzgdEwAoJJCbznhg6yn7QMgoxTjWw6t0JKuvgs0v/M=; b=WRjFpeODoHVVyc1Ta3CUALLAk9oqVAtNVuvTIo59fDPqMoNHyVZYjXlY7CZPBbThUl DqTsvuS7UODK65pPpbElefNpY8beTnxFmImaAYlX/htCFa2VvHwDfhNolk5l9Og1iFGH t3qAHf3k8RnczSWUXj0M0XhqN5VqUB2Cqsu7QFfJc5S/kLkvCNXxPapKPRDQjmpoROB6 yWkXcFsbo7q2uE/2CoraxCE9a60rgXRGvNgXL9j8wXgS1IpqGXE9rNCghDzfW7cTg35s HK+a5R2CwdSMg804ItCj2K6Q8FgGWRuS/UtkABFbQFNuZtX4e1XcwoWSXaJbbGIxdxKh X0zA== 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=ZTzgdEwAoJJCbznhg6yn7QMgoxTjWw6t0JKuvgs0v/M=; b=c45yBYrqYs2XamMHTEHKtJSilGw+fzZMMY7ctDBdRjT3rk6CuqK1994YxyDOTOKZm4 PMDgSHBXVrhcaNkbFflOB53w0bcdneSgJOSWPm3JPs7xS/kpWr9I1mToS0TmbyqXcNBc ZyXX3zp6E6NlQqyaQG9QQMy+yhk47xl8ISsWVZWiPzO2ftQamoh4wwIwzQu5mjUbSjRO 0wMNedwkY/pClAdKSbijse+wQ3XAVhEefltHWfnxC/eHOP1OgcVy1wZZ17ob5O4Hz4zV ZD/nuaM/q2trSx93GizxUi8x8FBkfMym0v6oYyQHgMN311054mixVkCT0qVYSsy6d1Td fYdg== X-Gm-Message-State: ANhLgQ3iBlcyNW8vv38XHi5zmahEMKGNil+21Gh64TEWW/QxtxKIwoNi RvgeLD3MxCYI5AkJIVW1duDhT5k1JqyycUTYxeQfLk9qKB8= X-Google-Smtp-Source: ADFU+vu5I8OxAL8WUj+xQVAPTSArt/q0JJg4jFWnjYvU9nt+H6Pa5qWmLGDUnqotE8tQWDquoOA7SflK0CtcFdak2Eg= X-Received: by 2002:a9d:74cf:: with SMTP id a15mr4470694otl.258.1584460337310; Tue, 17 Mar 2020 08:52:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 17 Mar 2020 16:52:06 +0100 Message-ID: To: Jakob Givoni Cc: php internals Content-Type: multipart/alternative; boundary="0000000000009119d605a10eeb87" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --0000000000009119d605a10eeb87 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jakob, wt., 17 mar 2020 o 03:08 Jakob Givoni napisa=C5=82(a): > On Mon, Mar 16, 2020 at 6:48 AM Jakob Givoni wrote: > > Let me know what you think! > > Thank you for your feedback so far! > > I'd be really curios to know what authors of the referenced RFCs think > about this, f.ex. > Micha=C5=82 (brzuchal@php.net), Andrey (andrewgrom@rambler.ru) and Nikita > (nikic@php.net) > > Is simple inline object population useful in itself? > Is the proposed implementation as trivial as I think it is? > For object initializer, I was hoping to introduce a feature which with the benefits of typed properties could reduce the boilerplate on initializing object and setting their properties in one expression. This is somewhat what I personally do a lot for commands and events construction where those simply have public typed properties and I don't care if something would be changed in the meantime. With current RFC for write-once, I can see object initializer could be an awesome feature with a combine of read-only properties. Currently I would have to do a lot of: $command =3D new SomeCommand(); $command->foo =3D 'bar'; $command->baz =3D true $this->dispatch($command); For SomeCommand looking like (with read-only for example purposes) class SomeCommand { public readonly string $foo; public readonly bool $baz; } With object initializer, this could be reduced to: $this->dispatch(new SomeCommand { foo =3D 'bar', baz =3D false }); But as mentioned IMO this is a different feature than what you propose and personally I see no point in reducing only assignment statements without combining it with object construction for these kinds of small objects, DTO's, commands, queries and events. And agree with others that brackets look unnatural for anything related to objects. IIRC there were many questions about named parameters to pass for object constructor or proper property setters like in C#, but personally I don't need a constructor at all in those cases since we have typed properties and it looks like they could be also marked as read-only in next major PHP version. Cheers, -- Micha=C5=82 Brzuchalski --0000000000009119d605a10eeb87--