On Fri, Nov 21, 2014 at 5:55 PM, Alain Williams <a...@phcomp.co.uk> wrote: > On Wed, Nov 19, 2014 at 07:17:48PM +0100, Julien Pauli wrote: > >> [Off Topic] >> >> It's been a long time I've been thinking about having a compile-time >> preprocessor integrated into our parser/compiler stack. >> I would design it just to support #migration tokens, and nothing more. >> This would really ease migrations, with no runtime impact at all, and >> the possibility to use any syntax, knowing it will get compiled, which >> is not possible nowadays. >> Like the C preprocessor. And it wouldn't be that hard to add to our >> codebase, as there should not be any runtime impact, just a two-pass >> parser >> >> Anyone interested can contact me :-) >> >> [/Off Topic] > > If you do, then please back port it to at least PHP 5.3 If you did then we > would > be able to write code with new syntaxes (that won't compile under > 5.3/whatever) > and automatically use them when the code is run under whatever version > supports > the syntax. > > Going back to the example that I gave & thinking a bit, a '$#' at the start of > line (not recognised anywhere else) would work. It is an error under different > circumstances and is sufficiently reminicent of C to be helpful of those of us > with that background. > > $# if PHP_VERSION_ID > 50500 > $# else > $# endif > > Without wanting to make it too complicated, it might be nice to allow a 'set' > (or 'define'), this would allow setting of flags, eg: > > $# if PHP_VERSION_ID > 50500 > $# set FINALLY 1 > $# endif > > $# if FINALLY > ... > $#endif > > --
Hello, We are (because I'm not alone anymore having this idea and already got private feedback) working on something much more simple, based on the declare() structure. The idea is to have something that could make PHP compile only syntax it knows, and not older syntax (prevent parse errors or use a better implementation). Obviously, this will not be pushed to stable branches, and could target PHP7 if we decide to push it to an RFC. declare(php_version >= 5.6) { function foo($a, ...$b) { } } Very first ideas, need more reflection, then an RFC draft Julien.P -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php