Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114266 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60561 invoked from network); 4 May 2021 10:52:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 May 2021 10:52:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6B6571804E3 for ; Tue, 4 May 2021 03:58:04 -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-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (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 03:58:03 -0700 (PDT) Received: by mail-il1-f182.google.com with SMTP id v13so5983572ilj.8 for ; Tue, 04 May 2021 03:58:03 -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=mKNXNAPV97k4kx8DEnrz/8AvpnDZPsZwEwi2NFziSjI=; b=QcUozu2iGUeFqtjan6Zbs8azoDGN/D14vtmqnFWD8WpbEsUbIqXCUNP7JTkjP7Bv3u OCRWjRrGjMjdxWg8hTgj48agCjlPZLz6DprFkzF6q61axN9prjIbcywbl4OLIvWxCjlA dy3K0rBY4S6dcccJomtwen8qpnKtgxXalSjaYjxv3a989pT4H6/Ta0VYVx5e7QTlOAsx g2Aui5Rz5LSFI/OHX38HI1TV4bc0/1E6HrNkBv57LVDGI5EfiE9MpgiN50ymtqvFTf+k 6vHNR+nhumXuItoc0HfwAfrCMCaIcng6XHWcpSAQg+UrQlcgFgxxxjiYjql+xG6c4qha Z1tw== 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=mKNXNAPV97k4kx8DEnrz/8AvpnDZPsZwEwi2NFziSjI=; b=X9RN8wVfodbwc64BDuwGaWC3EgZF186s+KnvNQ7ZkfgspV7wL0q75McjnymfUsgdpu aWXYFr09aj5yT8LiBIXKecUQSSUBkANIROfDY/4jB7yIcUtRMtbwslROsYLTP5G7GoX0 o50HryjaWMkzEXpO+sfa7I6Q7Dew4y8QNa90G365Kp3Fv1q7nK04RyTUMvURPq8Ek3ar 6xmaMfMNOiGK+DdRAiNdn4bWQp4IyDotD2nq0EuJODfoNU3LOCbYfJB3e+6FHgic8Bkb ktxWs+dNngQy19y8mCG8PxZ8somfElA7Y/94k7mS8nlHspGAlYtc6bqhyBBnuzq5B8ky /5eg== X-Gm-Message-State: AOAM5333LEM8VWpBi4SHsSk5OuaAs7AF4timK44h4MupJJLyGNiBfToC pUUo/FC61NIBrYek4l7mLO/Km6GxRV6Bc/auDic= X-Google-Smtp-Source: ABdhPJyXHJqMyvrbT534qk6qV/WNjvdjvKx2q4IoSfQxoFFsWPpBekkj+x+z/sbxYWfzSbeCYFIXNzVy8PAssoaTmZc= X-Received: by 2002:a05:6e02:1d06:: with SMTP id i6mr20103933ila.165.1620125882859; Tue, 04 May 2021 03:58:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 May 2021 12:57:50 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000bd46d705c17ef341" Subject: Re: [PHP-DEV] [RFC] Property accessors From: ocramius@gmail.com (Marco Pivetta) --000000000000bd46d705c17ef341 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 propert= y. > 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), an= d > 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 implementation= , > I've grown increasingly uncertain that this is the right direction for us > to take. The proposal turned out to be significantly more complex than I > originally anticipated (despite reducing the scope to only "get" and "set= " > 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 accessors > proposal would be captured by support for read-only (and/or private-write= ) > 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-ref 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. * 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) * what is the design decisions around same-visibility declarations causing compile errors in inheritance scenarios? Those would make BC unnecessarily complex, if a parent type declares a new accessor with the same name: variance is understandable, but same visibility errors seem a bit too much As for the rest: it needs more careful review. So far, good work! > --000000000000bd46d705c17ef341--