Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118548 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53618 invoked from network); 31 Aug 2022 21:27:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Aug 2022 21:27:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E6F2180505 for ; Wed, 31 Aug 2022 14:27:02 -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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 31 Aug 2022 14:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1661981218; bh=AsAWfL9DTshYAQe9fgYsGLd6hybhfi2pQqPn5mwnEGY=; h=Date:Subject:To:References:From:In-Reply-To:From; b=AHFO9aK8nAyO2jB6jZzo9ztApN1Yb2c3pSjmopjC0rhqKIh8E41lYsXVbRN0DIo4V hxa/XFQx0kVu1RlBhgHvnHHYXeyj5tjBKCTUoialxsQnFz+Xfh7hlFpjtuOPLCeEhx mTelX+8JbsV/j0sXf3m5YRDDEhZ+0ULVgLsAyKKJlxt4vnByr36yuhlK+NQR9Ib7m9 Vnw37PF/r3+gYUuVOuTBQ93Cil8wRZtsDFNtXhm0bDinC12JAoOy2l6TxLB8GbXLgV WaS0TiZX4JbYGK8Rx9wwvs7aynmE1f1Uw2W/nm+vPy5+83pKRMSIgdBjX9clOnd4Sn LlkI3H5bCz99A== Message-ID: <8fd0c415-181d-0d2d-da1c-2f71cfdc40c8@bastelstu.be> Date: Wed, 31 Aug 2022 23:26:58 +0200 MIME-Version: 1.0 Content-Language: en-US To: Larry Garfield , php internals References: <81b41335-afa1-40b7-9eb6-4664304812ec@www.fastmail.com> In-Reply-To: <81b41335-afa1-40b7-9eb6-4664304812ec@www.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Asymmetric visibility From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 8/31/22 22:43, Larry Garfield wrote: > ## References make everything worse > > […] > > That problem wouldn't happen if all we're changing is visibility, however. That means in the C# style, we would need to differentiate whether the block on the right is intended to disable references or not. Ilija has proposed `raw` to indicate that. That would mean: > > ```php > class Test > { > public $a { private set; } > public $b { private raw; } > > public function inScope() > { > echo $this->a; // echo $this->getA(); > $this->a = 'a'; // $this->setA('a'); > > echo $this->b; // echo $this->b; > $this->b = 'b'; // $this->b = 'b'; > } > } > > $test = new Test(); > > echo $test->a; // echo $test->getA(); > $test->a = 'a'; // Error, set operation not accessible > > echo $test->b; // echo $test->getB(); > $test->b = 'b'; // Error, set operation not accessible > ``` > > The take-away for the asymmetric visibility only case is that we would need to use `raw` instead of `set`, in order to avoid confusion later with accessor hooks and whether or not to disable references. > > The Swift-style syntax, as it does not require any hook-like syntax to just control visibility, does not have this problem. There is no ambiguity to resolve, so no need for a `raw` keyword. > I've read through that explanation three times, but don't understand why the C#-style syntax would require to differentiate between `set` and `raw`. Isn't the difference between "visibility only" and "accessor" not clear [1] by having either '{' or ';' after the 'set'? [1] Read: Clear to the engine, not talking about the human reader here. Best regards Tim Düsterhus