On 8/15/2013 10:42 PM, Stas Malyshev wrote:
note that we have this functionality already:

$ php -r 'class A { const C = FOO; } define("FOO", 23); echo A::C;'

The first fetch will resolve that.
This is true, but what happens is that "FOO" is stored and then resolved
on fetch with direct lookup. Now, if C = M_PI/2, what would we store? We
could theoretically store string "M_PI/2" and somehow "evaluate" it, or
we could even translate:

class A { const C = M_PI/2; }


class A { const C = __definition_of_A_C; }

function __define_A_C() { define(__definition_of_A_C, M_PI/2); }

and when we encounter __definition_of_A_C for the first time we run
__define_A_C() and take the value of __definition_of_A_C - but I imaging
that would seriously complicate the code, especially if we think about
how to handle exceptional situations there...
Stas, is there any currently existing standard "Just In Time" construct
in zend? Something like a Promise?

If there isn't, would it make sense to add this type of feature into the
core so that these types of needs could be handled with a Promise? The
late binding aspect is similar in concept to a Promise I believe...


Search Discussions

Discussion Posts


Related Discussions



site design / logo © 2022 Grokbase