Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36941 invoked from network); 21 Nov 2014 17:39:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2014 17:39:25 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.51 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.192.51 mail-qg0-f51.google.com Received: from [209.85.192.51] ([209.85.192.51:62794] helo=mail-qg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/02-26013-BC87F645 for ; Fri, 21 Nov 2014 12:39:25 -0500 Received: by mail-qg0-f51.google.com with SMTP id l89so3951673qgf.24 for ; Fri, 21 Nov 2014 09:39:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=/iPJKrpWbwA1U+ETBs1aWJQcKLMbo87EzN+WBdseEFM=; b=N5mflMoZsVDXDiw3dnYiZ6sTOaeiHj9WylIBD6YlObKCxkEePnqOMYo6nNmknoDc0z 4h3oBC21/fSMba4qYbvIjTJDscucfo5PgnMwb7QdrctK+KZnXGfx1aQzeoXZs4OzgY6/ xOg143mjQKdLZeNvS3nSJAaKZXrTChr7G6+eklEirvknkZrweByut8supIhbgn6OuZRZ 5WsJhdZspayU7jxs00kNJWU8e+09+5J20BsVeNd/zITJTK/yQj6XqC6TRDwXqUFOcyhI xNUreZxoBTTpVhmvaQrNPMSX27AWwc9iXNWycjZ9eaWyRdjxcYG2+/wA4Os5nwhkzjs2 XyFQ== X-Received: by 10.224.131.135 with SMTP id x7mr8242852qas.38.1416591559162; Fri, 21 Nov 2014 09:39:19 -0800 (PST) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.140.20.86 with HTTP; Fri, 21 Nov 2014 09:38:38 -0800 (PST) In-Reply-To: <20141121165522.GA7217@phcomp.co.uk> References: <546C9E22.6090301@fedoraproject.org> <20141119134632.GV2294@phcomp.co.uk> <546CA8C0.1060707@gmail.com> <20141119150713.GY2294@phcomp.co.uk> <4183E34B-0A7A-484E-8A04-411A309F4291@ajf.me> <20141121165522.GA7217@phcomp.co.uk> Date: Fri, 21 Nov 2014 18:38:38 +0100 X-Google-Sender-Auth: bExPw9FEmcnBLIptJ6a83b6yfS0 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [OFFTOPIC] conditional compilation, WAS [RFC] Remove PHP 4 Constructors From: jpauli@php.net (Julien Pauli) On Fri, Nov 21, 2014 at 5:55 PM, Alain Williams 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