Re: [RFC] Constant Scalar Expressions
| From: | Patrick Schaaf | Date: | Fri, 16 Aug 2013 07:43:00 +0000 |
| Subject: | Re: [RFC] Constant Scalar Expressions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68546@lists.php.net to get a copy of this message | ||
Am 16.08.2013 01:42 schrieb "Stas Malyshev" <smalyshev@sugarcrm.com>:
>
> But this is not the most tricky part. The most tricky part is this:
> if(true) return;
> class Foo {
> const halfpie = M_PI/2;
> }
>
> Now what happens if this is implemented as an opcode? We can't run any
> opcodes past return statement, but Foo is expected to be defined here.
Couldn't the opcodes for such behind-the-scenes initialization be generated
as the first thing of the '(main)' opcode stream, so that they would run
before it comes to the "if (true) return;" ?
Once that is in place, make classes have an optional on-first-use opcode
stream, too:
- emit calls to that in the file's up-front opcode stream for each locally
defined class that has them
- in that per-class initializer stream, expression evaluation even for
non-constant initializers (protected $foo = anything::whatever()*10;) could
be put
- and also a call to the much talked about static class initializer function
- all in strict definition order, with fallout related to interdependance
left to confuse class authors :)
best regards
Patrick