Re: supporting the final keyword for properties
| From: | Amaury Bouchard | Date: | Tue, 28 May 2013 09:20:10 +0000 |
| Subject: | Re: supporting the final keyword for properties | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67580@lists.php.net to get a copy of this message | ||
2013/5/28 Maciek Sokolewicz <maciek.sokolewicz@gmail.com>
> It’s a good idea in general but what about having it for variables as
>> well? Could open interesting possibilities for an optimizer.
>>
>> final $foo = "str";
>> $foo = "bar"; // bails out
>>
>> Don't we already have that? It just has a different name: constants.
It's different. You can manipulate variables in some ways you can't with
constants.
This code, for example:
$a = 'abc';
$b = 'a';
print($$b);
It will display "abc". It's currently not possible to do something similar
with constants.
I think the subject was already debated, but I wonder why we should write
that:
final $foo = 'bar';
instead of:
const $foo = 'bar';