2013/5/28 Maciek Sokolewicz <maciek.sokolew...@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';

Reply via email to