Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78426 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56768 invoked from network); 28 Oct 2014 14:04:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Oct 2014 14:04:42 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.181 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:65043] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/35-21571-972AF445 for ; Tue, 28 Oct 2014 09:04:42 -0500 Received: by mail-wi0-f181.google.com with SMTP id n3so1701011wiv.8 for ; Tue, 28 Oct 2014 07:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=/621hDN3WOcNBr+X4SskbSrcnMPplSCJ3GjatKoWzaM=; b=gVKc1M7dMizlhNcIQoiYw3wYvd8sbptCHPY/XjAyngY/CJsAUUXXCLmrBfSYHOJXC0 2C2WWMKLsU8DXokp1cDGJFINCck316Y6VTtoN6ZtbbjDss3JA6v5ti4CgT+YdQ0eKIlY 8+Al9ZzKZMtWNpRFvg/HC5s4Hlr0TU/Zvf83d2yrieeCXFmKceM9/7FOq/jUpbP/2B/N LHazpJ99s5/4ywl5kbXxIqoHWOe6cnKs+YxdvxcKS0UQwwms9uR1iYtHGKBJwPkqM+pS CVvqaqGTSeWgeG9rpTsUUEZbnQtH+ahwJCIh/kFd/G1HNv3cRUAZSOO1o55ZqVRev/UL mWSw== X-Received: by 10.194.79.201 with SMTP id l9mr4508890wjx.59.1414505079168; Tue, 28 Oct 2014 07:04:39 -0700 (PDT) Received: from [192.168.0.177] ([62.189.198.114]) by mx.google.com with ESMTPSA id ge1sm15534949wib.4.2014.10.28.07.04.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Oct 2014 07:04:38 -0700 (PDT) Message-ID: <544FA274.2090306@gmail.com> Date: Tue, 28 Oct 2014 14:04:36 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "internals@lists.php.net" References: <6E04B9BE-854E-4112-8C74-7D90BD8BFE95@ajf.me> <544D48A3.6070905@gmail.com> <572FEBD1-99A8-4788-83F9-D99E470FB16D@ajf.me> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Readonly Properties From: rowan.collins@gmail.com (Rowan Collins) Chris Wright wrote on 28/10/2014 09:46: > I would suggest something like this: > > public $foobar { > get { return $this->bar * $this->foo; } > private set($value) { $this->bar = $value / $this->foo } > } > > ...where only a single visibility modifier is permitted on the left, > and this is treated as the *default* visibility for the accessors, > which are free to declare another visibility if they want - so the > following would be equivalent: > > public $foobar { > public get { return $this->bar * $this->foo; } > private set($value) { $this->bar = $value / $this->foo } > } The reason I opted for using var rather than having modifiers on both sides was because I wasn't sure what should be done with expressions like this: public $foo { private get; private set; } Is that allowed, and actually creates a private property? Or does the compiler detect it and give some kind of error? It feels like a bug in the syntax that the same information is included in more than one place, meaning it can express contradictions. -- Rowan Collins [IMSoP]