Re: Idea: ifdef-like feature to ease userland BC

From: Date: Sun, 09 Mar 2014 08:35:38 +0000
Subject: Re: Idea: ifdef-like feature to ease userland BC
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-73026@lists.php.net to get a copy of this message
Am 09.03.2014 06:41 schrieb "Stas Malyshev" <smalyshev@sugarcrm.com>: > How is it supposed to be implemented? PHP has no separate "compile-time" > than can produce significant improvement in performance, like C-like > languages do, and given opcode caching, such conditions should either be > resolved statically - which means limited usability, as you'd have to > drive them off something that you can use no code to define, or use some > logic to resolve them dynamically, which logic would probably take > nearly as much time and space as regular if() would. Such compile-time optimization, especially regarding opcaches leaving out entire blocks of code completely for the rest of their livetime, can be sanely driven, as far as I can see, exactly for the set of constants that have already been defined at the end of MINIT. A single bit giving that meta information on the constant, would suffice to signal that possibility. That would basically be all constants defined by PHP core and loaded extensions, Which might already be, in my eye, a useful thing to support, providing dead block elimination for PHP version constant compares, tests that certain socket flags are present, and so on. To me (and others when they would use it), it would be even more useful when a "configurable constants" extension like PHP-Defcon (see github) is used. We use that to define diverse server-type constants on different servers all using the same PHP code base. Now, all that does not need new syntax - "just" a compile time evaluation of any branchy constant expression regarding "does it use only literals and constants already defined at the end of MINIT". Maybe I'm stupid to not know that APC and/or opcache already does that? Couldn't see it immediately so I thought I'd write the issue down. best regards Patrick

« previous php.internals (#73026) next »