Re: [RFC] Accessors : read-only / write-only keywords

From: Date: Sun, 21 Oct 2012 15:23:53 +0000
Subject: Re: [RFC] Accessors : read-only / write-only keywords
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-63587@lists.php.net to get a copy of this message
I would like to point out that in my mind const and read-only are not necessarily the same thing. Read-only means that from outside the class it cannot be modified; the internal class can change it whenever it wants. Const means that once the value is set it will NEVER change. Big difference. Also, I feel like there is no need for the read-only keyword. Defining a getter and not a setter should suffice in my opinion. The absence of the setter declares intent well, in my opinion. If for some reason you need to enforce that nobody inherits it and sets the property, then declaring a setter and issuing an error or exception would suffice. Let's not clutter up the language for such a simple idea.

« previous php.internals (#63587) next »