Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115226 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99091 invoked from network); 30 Jun 2021 08:16:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jun 2021 08:16:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 26A9F1804D8 for ; Wed, 30 Jun 2021 01:36:31 -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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 ; Wed, 30 Jun 2021 01:36:27 -0700 (PDT) Received: by mail-qt1-f170.google.com with SMTP id w26so888394qto.13 for ; Wed, 30 Jun 2021 01:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=+L0ivqnxP0biyOx0fQVcDI/T6twtONrl5H1f4Wjy6tc=; b=f9QL7MKuSRbaNCsmiwcxPeVp9CYd1Ygtzx5tnsJ5n1pLj/yf3JEhvmwPuGKizHHxsK MFO+/ASTt0/9XtdPKYJBxgWzgQJw6faSiixHxtd2SUCJCbU6XnPgSxcQj6Jc0ru6Dxr5 RbDMdZ1GaI2uHOEBTb9lbmE5YvU0dGRwKEZus9l3npF8v47y3T0AZcGHS4QslQXKP+Ow Syqxx7PKyYbo/n9GPg+T6ZmlAuAZg53r4hkvkJQ2LHbHr+zxCEk0syU2aNz0wpz0Kwh5 oh5py2SRM15RO9vMa711acAsTev2a5JNCkMYkX3FAIPmIJRyrR35g4N5uTyKCGSecM8n SVjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=+L0ivqnxP0biyOx0fQVcDI/T6twtONrl5H1f4Wjy6tc=; b=JS8iBH3HuC/VMKVGRmkFAaA0DbnABNAfNHwtbX+YM2/sASAh6oB2T1naTjVAeCjQ4T 6ZWg6H+713pere3xvyDJVDvcU8SLDMKmTSafbVImFNlzS6ZkC4H5Mv8iW0uhFzXI6P1n kOeGfE+LxJZhikpZk8hO16S6JdY6PCvlZZ627Qi1tSTv9CZAwzI/AJtYlGKkiZaQgFgX VIiZf/if+zH/8DqLOcke6LjNL5nPzZhQWCsP+zs1wZeVSaEf6xL56vvrioIrHUitSIf6 NY7bfbyeuc39QgWE7Qw9Fv0FE7kwJhkD5+4NivbDIkb9U+wHQQNPVoIG1BiiMWwFMzOe 5Iaw== X-Gm-Message-State: AOAM530We8GLCHUrsf5VKUnoomz0IZvrQ8qQQmgZHWI5/EOkPylU0/Yu m1ttJBWRaHrZljVn+ziJBzBneGE/M8PhmNMfh8k= X-Google-Smtp-Source: ABdhPJwMqL3L8mbb4paig5/01Lcp2ECdplUBxHNlVsz6pQwcplKus1JPYHgnnQGX+A4L7Xgsauk9X4p1mIaZ9wuUTY0= X-Received: by 2002:ac8:5813:: with SMTP id g19mr31107563qtg.383.1625042186756; Wed, 30 Jun 2021 01:36:26 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 30 Jun 2021 10:36:15 +0200 Message-ID: To: larry@garfieldtech.com, Nikita Popov Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Re: [RFC] Readonly properties From: andre.romcke@gmail.com (=?UTF-8?B?QW5kcsOpIFLDuG1ja2U=?=) > > It's okay to vote against this if cloning is a deal breaker. In that case > > I'll probably either work on cloning before re-proposing this, or pivot to > > asymmetric visibility -- it's not my first preference, but it may be the > > more pragmatic choice. Cloning is definitely the weak point of this > > proposal. > > I already went through the clone-arguments mental exercise in my earlier analysis, and the code > it produces is totally disgusting. :-) clone-with is a considerably better approach if you're starting > from readonly. (It's also better if you start from asymmetric visibility, although that version needs > a clone-help feature far less.) Internals have been here before, it's a recurring problem in PHP that fundamentally missing features are voted down because people want other complementary features first. read only has been voted down by people rather wanting type properties first, or rather wanted assessors first. And then in turn accessors multiple times were voted down by the other 2 camps. But these features are interconnected and need to be done step by step, during the process things won't be perfect either way, Now we have read only vs clone with vs accessors vs ... IMO problem caused by no clear roadmap / vision of the project that people can be united behind. -- Anyway, even though I tried to push for asymmetric visibility last year I'd gladly vote +1 on this. It's not perfect, but it's the right direction, and there are multiple starting points to get there. This solves 80-90% of the use cases out there for read only properties, which is a very good start. -- Nikita: Probably a small thing, but the only detail I'm unsure of is why focus on write-once logic? Why not aim for aligning it with a future *:init visibility, where I would think the property in PHP should be writable in __construct(), __destruct() and __clone(). This won't solve the separate clone with feature request. But it would make it more flexible and language design wise would set it up for possible asymmetric visibility + init option later. For now it would at least allow setting default values on the property, for instance if argument to constructor is not 1 to 1 with property type/value and needs some light logic in __construct to determine if property should be set to something else then default. But again, don't see a blocker here in current RFC, as it starts out with a narrow scope of read only, and this can be widened later.