On Wed, May 19, 2010 at 1:49 PM, Christian Schneider
<cschn...@cschneid.com>wrote:

> fqqdk wrote:
> > How about extending the usage of the 'final' keyword to support a
> java-like
> > syntax?
> >
> > class Foo {
> >    private static final $bar = 'ex' . 'pression';
>
> In my book "final" in Java gets an award for sickest abuse of a keyword.
> So no, I don't consider this an option. Simply use a class variable (or
> define()) if you need to store some runtime calculated value.
>
> "But <insert other language> can do this" alone is not sufficient as a
> reason to bloat PHP IMHO.
>
> - Chris
>

I think that is pretty subjective, but I did suprised when I found out, that
the global scope constants behaves differently than the class consts.

Allowing the class consts to be initialized in runtime(if neccessary)
wouldn't breake any php application, only slow them.
Can't we do something, to allow broader usage of consts without sacrificing
performance?
So I propose to add a new syntax: literal.
literal should behave how the const behaved, and const should be initialized
in runtime.
maybe we could check from runtime, that the const was a dynamic value, or
literal, and generate a notice for the developer to change the const to
literal for gaining performance.

What do you think?

Tyrael

Reply via email to