Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78299 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79606 invoked from network); 24 Oct 2014 10:22:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2014 10:22:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Received: from [78.32.209.33] ([78.32.209.33:57197] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/B2-62277-8482A445 for ; Fri, 24 Oct 2014 06:22:01 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.72) (envelope-from ) id 1Xhc0L-0005H1-8o for internals@lists.php.net; Fri, 24 Oct 2014 11:21:57 +0100 Date: Fri, 24 Oct 2014 11:21:57 +0100 To: internals@lists.php.net Message-ID: <20141024102157.GO4025@phcomp.co.uk> Mail-Followup-To: internals@lists.php.net References: <6E04B9BE-854E-4112-8C74-7D90BD8BFE95@ajf.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Parliament Hill Computers Ltd User-Agent: Mutt/1.5.20 (2009-12-10) Subject: Re: [PHP-DEV] [RFC] Readonly Properties From: addw@phcomp.co.uk (Alain Williams) On Fri, Oct 24, 2014 at 10:41:38AM +0200, Patrick Schaaf wrote: > Am 24.10.2014 01:36 schrieb "Andrea Faulds" : > > > > Here’s another RFC: https://wiki.php.net/rfc/readonly_properties > > +1 for the general feature, I'd love to have that available. > > I have an idea regarding the additional keyword, with a small implication > (improvement) to the functionality provided, but at the cost of being > slightly quirky :) The idea is: > > public $foo as private; > public $bar as protected; > protected $baz as private; > > where the "as X" gives the writability scope. This introduces no new > keywords, and is currently not valid syntax, as far as I can see. More as musing than anything else - might provide some insight via an analogy. Properties and methods have a scope that is: private, protected or public. This reminds me of the Unix: owner, group & other file permissions. Unix allows: read, write & execute. This RFC is trying to control how a property could be used with a readonly restriction. Are there times when one would want to be able to set a property value - but not read it ? Thinking about execute - would there be any mileage in an execute permission - could be useful for a property that had been assigned an anonymous function. Finally we could bring it all together and sidestep the scoping keywords using 'var' instead. Thus: var $callback as 0751; Would define a property that contains an anonymous function that could be called by anyone, inspected by the class & related class, but only set by the class itself! -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include