Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114269 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78448 invoked from network); 4 May 2021 14:11:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 May 2021 14:11:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C27711804B5 for ; Tue, 4 May 2021 07:17:50 -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, 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-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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:17:50 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id w15so9994469ljo.10 for ; Tue, 04 May 2021 07:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=rWDI2vSRtqaZBELQ330p8G5IcwZ3/bkuA1WzvaTpexw=; b=LX091tcPKcjZWOfqjzGP+5B56GzUst8QeBLFr+F7gAN1lXMwxpjX80B1uOtCKFYQeX 77t9rQUVEa45rqg9I4Z3vi/AGEEAbk96QaEg4A1SFo9PNlrwEp0gdUMWYMSNQgEO82TH bilxwYYLnj64Q9urHN8qe1WOPrVMGWSmnqSCBj2IZTCCbWP17kXvx9Kz5mEFtbBd2H2t l7NIg8H3LZJof+6Nje3sG2OdgGxWAwr4APVJte2cgydenVmNQwv5xrlh/llvmhvIdLwV j5nBlUagnySQB1RUHiLbWpQlQHEVwq0gaLV+25BtBw20af21NiC6pEQzO/ck9dlVKJ/N h4gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=rWDI2vSRtqaZBELQ330p8G5IcwZ3/bkuA1WzvaTpexw=; b=qkSZY2AXIFaKyMrDkALj6oFlDogG0OAPq5V0jkDlD+nuYgBCRimkDhdv0DD58kaRoC 2Lvkf0TvWwMYBTqURVMe162vd966MEyb7Lxr5i8NpIbQSQD6nOA8eQM5416zV+ncs4kx f1ftV++2ymEWkI/hfHhUcw7tyiOlfWBKRu8MCZe+Uy6BBNHxQO7HvoVE+CRSFgiK2sFA M8qGquITDA4XD+ywEjhzpHV/03t9YZHYaEru5T+MJC8ROXYCYDglF0gR4HxLy/FjRfgx RqNi+0DQ2s4Ml50xx4kcK7EfY3uM94TDq6RkaV122lFxDxtxDWX1vO+9omS/kNgNuyD4 qbbQ== X-Gm-Message-State: AOAM533t1Afe2j8YwZU2pgRRi6SY6l5OKvZpfJmAX+GTdJLegChcCPIh b0FgeUNm9yMw7dvFpYVllOv+vu2XiCXuYPIK5kg= X-Google-Smtp-Source: ABdhPJzrRzUNplm8Q07EATVqxdobjniJeHig+r7aSSzOUJZbmq2Uegbg3TJ8m+c4QY0Gq/tKZBWp3vLsTaYr/U9h0sE= X-Received: by 2002:a2e:8e63:: with SMTP id t3mr10471374ljk.71.1620137867987; Tue, 04 May 2021 07:17:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:1102:0:0:0:0:0 with HTTP; Tue, 4 May 2021 07:17:47 -0700 (PDT) In-Reply-To: References: Date: Tue, 4 May 2021 16:17:47 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Property accessors From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2021-05-04 15:57 GMT+02:00, Olle H=C3=A4rstedt : > 2021-05-04 12:33 GMT+02:00, Nikita Popov : >> 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), >> and >> 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 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 >> "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 accessor= s >> 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. >> >> Regards, >> Nikita >> > > Hi, > > In general I'm no fan of trivial getters and setters at all in OOP. I > think a better solution is provided by: > > * readonly properties (or write-once, in the constructor) > * namespace- or package-internal accessing; "internal" as an > alternative to public/private > > Especially when getters and setters do not upheld any particular > invariants or check validation. > > Note that namespace-internal access cannot be provided by getters and > setters (though technically it's a big and hard change to PHP, AFAIK). > > Olle Or maybe I shouldn't be a complete idiot and actually carefully read the RFC before any knee-jerk reaction. Disregard. Olle