In that case, we should use what C# calls it, "readonly". Writable
only once by the constructor.

On 16 July 2012 14:35, Nikita Popov <nikita....@gmail.com> wrote:
> On Mon, Jul 16, 2012 at 2:25 PM, Ferenc Kovacs <tyr...@gmail.com> wrote:
>> Hi,
>>
>> The recent http://www.mail-archive.com/internals@lists.php.net/msg59301.html
>> discussion
>> made me wonder why did we decide not supporting the final keywords for
>> properties as it would provide an easy way for read-only attributes (const
>> would be a better choice in performance wise, but then you can only set it
>> in your declaration where no dynamic expression is allowed.)
>>
>> I would like it to work the same way as it does in java(
>> http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.4) eg.
>> you can set the initial value either in the declaration or later on, but
>> after it is set, you can't change it, trying to do that would create a
>> recoverable fatal error (or throwing an exception which extends
>> RuntimeException).
>>
>> What do you think? Would this be viable? Is there any still-present reason
>> why we shouldn't support that?
>
> I don't like this overloaded meaning of "final". "final" currently
> means "cannot be overwritten by inheritance". This would add a second
> meaning which would be somewhat similar to "const" (but only
> somewhat).
>
> Nikita
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
Andrew Faulds (AJF)
http://ajf.me/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to