Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110783 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34136 invoked from network); 29 Jun 2020 17:30:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jun 2020 17:30:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6C1EA1804E4 for ; Mon, 29 Jun 2020 09:19: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=-2.1 required=5.0 tests=BAYES_00,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-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (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, 29 Jun 2020 09:19:19 -0700 (PDT) Received: by mail-io1-f52.google.com with SMTP id q8so17792809iow.7 for ; Mon, 29 Jun 2020 09:19:19 -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; bh=5Luq1e38TKi18DLXxDClR8rYFRCRVQva9igelJ+guoY=; b=GOo0/tBL9LHcMD0yu7RNDu+PK1ORMG39tqAsZ513oBUfcvLX+fxZTPaQfszyhLv2jb C+SfMygtSG3KmwBiI5LTm13uibDo2GQUXtUklprca5/isvmQszTytgrKGdmegRmyirL2 AKJ8hnIvG02k2SlEneGCGK0+1ym769SkVXPdEL2woZ3jyiEdQ1u3XPeqNC/G9+Dh9UIg IgJcIq9z3D+LdjNxQrKu01sBIQv4zXQ6tnipGIUt1D3OYJFTX0BUBHNioEmL8z431+rz 0YiHcvmME+QcXM02UFIS7Uog6xQ1Hk69rx0YVO/GkEzNXDp1HJnrZat2nQSL/KgCSmGd Xs+A== 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; bh=5Luq1e38TKi18DLXxDClR8rYFRCRVQva9igelJ+guoY=; b=K3bPcz7DnF+4n1CHHDnM61LBfRlIlmylZFBhhf9D8zZ0rAHYeHKaumd5/StaNp4AU3 zEzBP3uL5Zz1qwxWM1WysUT/HNf0jBP/RMkjXDGUf/Uq69FETAdS3oo1Y4xTnziQnQe8 SYptOOQMvKQiTtyOPveI+EFL+fpEjXWGS5FMARNekuJjMHaH18qZcUrP4+AusYcGWhi6 hHWnKop49CwxFzpZXZkL7qNsjppTRg1lQcf1RPmuWWT+Ec806ZXaz7oOM1OJaMk8lJ/Z /ZgeCbYTPXi9x3sSkZU8pMqvBuDlr806Di3MdO+q/lb6ZLVxt96hwwo+2ID24bzVGMRx wMGg== X-Gm-Message-State: AOAM53041oWlthv05z03acsvQwV5u0AFjcs1OT5YWvXdSPdtqguUalc4 9xyPaGSW+oFDXWpDSejjNZ2lxX3OPTzp4TJYr+/RH6fg X-Google-Smtp-Source: ABdhPJwNEyJqKkwhSUM7NreFVZmTNld0HouSysG57iIh3UUPCTZVWSwe9/E9kNXxEUDOJT3pRL/39oKZ1EW4e5D/A58= X-Received: by 2002:a05:6638:252:: with SMTP id w18mr5799697jaq.42.1593447559018; Mon, 29 Jun 2020 09:19:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 29 Jun 2020 17:19:07 +0100 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000b939e905a93b6b13" Subject: Re: [PHP-DEV] [RFC] Property write visibility From: rowan.collins@gmail.com (Rowan Tommins) --000000000000b939e905a93b6b13 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 29 Jun 2020 at 16:44, Marco Pivetta wrote: > property accessors seem to perpetuate the bad practice > of getters and setters > Outside of access restrictions, a common use case I've seen for property accessors is lazy-loading, which I know is something you use in other forms= . > M=C3=A1t=C3=A9 also linked today ( https://twitter.com/kocsismate90/status/1277625002720968704) that C# 9.0 is getting init-only properties, which looks similar to the RFC linked above. Note that in C# the new "init" keyword is explicitly an extension of property accessors [1], and relates specifically to "object initializers", which PHP does not have; a proposal for them last year [2] was rejected. An existing "readonly" keyword [3] allows you to write a variable only in the constructor, and "init" is mostly needed because object initializers are run too late for this. C# 9.0 also has a bunch of features around immutable data structures in general, including a variant of object initializers called "with-expressions" [4] to solve the "modified clone" problem. [1] https://github.com/dotnet/csharplang/blob/master/proposals/init.md#detailed= -design [2] https://wiki.php.net/rfc/object-initializer [3] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/= readonly [4] https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/#with-expression= s --=20 Rowan Tommins [IMSoP] --000000000000b939e905a93b6b13--