Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114270 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79985 invoked from network); 4 May 2021 14:15:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 May 2021 14:15:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2AA451804D8 for ; Tue, 4 May 2021 07:21:43 -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-Virus: No X-Envelope-From: Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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, 4 May 2021 07:21:42 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id t11so12028932lfl.11 for ; Tue, 04 May 2021 07:21:42 -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=LQUz/3mSjr4tOJJZzkzERXf+H9+MoPQ5QA1Af2P5TJU=; b=XWe4s5neMYEeIdt0qjkEF/LyI89sQ+PF1MMNKzRHQGcu8mZrTKfnexV0iPVY3fQ4iX Po/bTU9Ojg6CXmozS/RLnSh3M1LTfEr8IU9ajZTY4Tfr6oM6sGip7OQAPE4DsTpYh37K vgrQTbKu+DHdQhP0BKtIWmqkBL65/c6ZnJGJpSMsNjOM0/P2tF9QTV2iYKVM/Lmulozj +t/55j0hNT/QdyPdbSVwg46nXkFqp47G+XiP9G3UP9XnKvUVgMctbj9rCfjA5eZj2LJm VW7yFMo8smjBz6m7wKGokYYr2kMmfXm/A5A65WPlAjHk6aaj41jJ+G5bO3cQVDIDusO/ XXcw== 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=LQUz/3mSjr4tOJJZzkzERXf+H9+MoPQ5QA1Af2P5TJU=; b=Ncdg4FPMH3kn6x/iBT9VGoXi+ojl8pf0aUbpR+D1wsQZQkfpY8BKIdP9jVIquzdscw kt3eOKP7GBnUdyvpRztTNPP9GX+Rsv5CyJ9oymjWSKtEU3qTcPpYRSVB7V9bn3qbu2UY UtpPBWyF4nSHS/JGp4DrKR+uaF8o2GFh/VT4ugzaiUiO0JsemAzK4ZTR45cYjmcvNo3W bdgmUdBQ2MSQW7WwANbgDpEJCJJe0aLaU8neVZn2p/JTqr8X0/+Y9/eoLsL8uTsjCs+K pKHq4uxZUxTRgH116siso9xyuWMxEdG1f5nWkJX0iz1NPvxyYOsJT4ppf9R+pLumlF+f 02zQ== X-Gm-Message-State: AOAM533Zz1JDnpwfifCBYYrMJbycCY5uxriUgUMP6rMzVdtCykc4x9TR 3vpynfUyULbnGEcle2Qcsjeg8phOCDgOuRnVZZg= X-Google-Smtp-Source: ABdhPJzv/pLbwTdTb3Vn7fPasq7vFfTLiRFiS7cUQTzdiRCPP9q9WvF2zn4CajrouXpf2S1U39BxoY9r22yXFIMqqsg= X-Received: by 2002:a05:6512:972:: with SMTP id v18mr2594916lft.485.1620138099856; Tue, 04 May 2021 07:21:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 May 2021 16:21:23 +0200 Message-ID: To: Marco Pivetta Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000edd80405c181cb18" Subject: Re: [PHP-DEV] [RFC] Property accessors From: nikita.ppv@gmail.com (Nikita Popov) --000000000000edd80405c181cb18 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 4, 2021 at 12:58 PM Marco Pivetta wrote: > Hey NikiC, > > On Tue, May 4, 2021, 12:34 Nikita Popov wrote: > >> Hi internals, >> >> I'd like to present an RFC for property accessors: >> https://wiki.php.net/rfc/property_accessors >> >> Property accessors are like __get() and __set(), but for a single >> property. >> They also support read-only properties and properties with asymmetric >> visibility (public read, private write) as a side-effect. >> >> The proposal is modeled after C#-style accessors (also used by Swift), a= nd >> syntactically similar to the previous >> https://wiki.php.net/rfc/propertygetsetsyntax-v1.2 proposal. >> >> While I put a lot of effort into both the proposal and the implementatio= n, >> I've grown increasingly uncertain that this is the right direction for u= s >> to take. The proposal turned out to be significantly more complex than I >> originally anticipated (despite reducing the scope to only "get" and "se= t" >> accessors), and I'm sure there are some interactions I still haven't >> accounted for. I'm not convinced the value justifies the complexity. >> >> So, while I'm putting this up for discussion, it may be that I will not >> pursue landing it. I think a lot of the practical value of this accessor= s >> proposal would be captured by support for read-only (and/or private-writ= e) >> properties. This has been discussed (and declined) in the past, but >> probably should be revisited. >> > > I've skimmed the RFC: it will take a lot of testing to see how much this > impacts BC, but potentially a lot. > > A few things that came up so far: > > * instead of allowing by-ref `get` declaration, can we just kill it here= , > before it breeds again? I don't think I need to explain the woes of by-re= f > to internals, but removing the ability to declare new accessors by-ref > would be a huge win for the engine and the language long-term. > The primary functionality by-ref get is needed for are operations on arrays, such as $foo->bar[] =3D $val. This probably isn't particularly important for explicit accessors, but may be a non-trivial limitation for implicit ones. For example, you wouldn't be able to have a "public get, private set" on an array property, for all practical purposes. Of course, we could allow that to work fine for implicit accessors, without any by-value vs by-reference get distinction. Would probably open up questions regarding compatibility during inheritance though. Of course, I am generally sympathetic towards killing references with fire :) * what does an array cast of an object with accessors look like? I assume > only properties backed by storage will appear? (Yes, the array cast is > still the simplest/most useful pure API to inspect object state =F0=9F=98= =81) > That's correct. This is mentioned in https://wiki.php.net/rfc/property_accessors#var_dump_array_cast_foreach_etc (I've renamed the section to make it clearer.) * what is the design decisions around same-visibility declarations causing > compile errors in inheritance scenarios? Those would make BC unnecessaril= y > complex, if a parent type declares a new accessor with the same name: > variance is understandable, but same visibility errors seem a bit too muc= h > I'm not sure which error you're referring to here. Could you share an example (or point me to the example in the RFC)? Regards, Nikita --000000000000edd80405c181cb18--