Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79005 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66895 invoked from network); 19 Nov 2014 18:18:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2014 18:18:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.52 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.216.52 mail-qa0-f52.google.com Received: from [209.85.216.52] ([209.85.216.52:42401] helo=mail-qa0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/72-51809-6FEDC645 for ; Wed, 19 Nov 2014 13:18:31 -0500 Received: by mail-qa0-f52.google.com with SMTP id dc16so802742qab.11 for ; Wed, 19 Nov 2014 10:18:28 -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:cc:content-type; bh=9YmOEjon32H4UUym/NOwjrBkcoQtdp66C10ynPVYptM=; b=iw4XFqquIh7V0Z+8FUMQKuK6zVcZfIxUc2RRexRukD7oUaKhGL1V6HhsHujjWAGSeM yPgDQccO6LRkYRH1DMvTzqo3zXL6PrRhqE2S0SFgczOSoHR9sRVBCnyjxx7PYevCJbl5 n7V/giSBJ9vFaiXg3mmeVGK8SksT6tnA3C2cNNk8uqELhRGcSkjqleqgYiEgI6hGF9BS jYQwrOJQyJdYNmKe/WER9O+Fm/yBy3HKTSGQ1Qi6Jyfk10NGfvUVOsfWdP0tqGbj1tPa vagETTra1Ez2W4KlXF0f1FzPQvLzzV2kyp9v9rrq4sV87+YZlPImUK3u+IkzCWK27n8R ll2A== X-Received: by 10.224.131.74 with SMTP id w10mr54503975qas.81.1416421108501; Wed, 19 Nov 2014 10:18:28 -0800 (PST) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.140.20.86 with HTTP; Wed, 19 Nov 2014 10:17:48 -0800 (PST) In-Reply-To: <4183E34B-0A7A-484E-8A04-411A309F4291@ajf.me> 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> Date: Wed, 19 Nov 2014 19:17:48 +0100 X-Google-Sender-Auth: JxuuuMln-ebS-gySi34YoW4l9XE Message-ID: To: Andrea Faulds Cc: Alain Williams , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Remove PHP 4 Constructors From: jpauli@php.net (Julien Pauli) On Wed, Nov 19, 2014 at 4:10 PM, Andrea Faulds wrote: > >> On 19 Nov 2014, at 15:07, Alain Williams wrote: >> >> It is a problem trying to maintain code for different versions of PHP, >> especially where there are syntax differences. It would be really nice to have >> some sort of conditional compilation as in C. Eg: >> >> It would be nice to be able to do something like: >> >> try { >> .... >> >> # if PHP_VERSION_ID > 50500 >> } catch(PDOException $e) { >> .... >> } finally { >> ... tidy up >> } >> # else >> } catch(PDOException $e) { >> ... tidy up not quite where I want it >> .... >> } >> # endif >> >> OK: '#' might not be a good character since it is start of comment, but that is >> the idea. > > You could actually run the C preprocessor on your PHP codebase if you wanted! > > But yes, I can see there might be a need for conditional compilation. To a certain extent we already have this, in that you can conditionally define functions and classes. Perhaps this could be extended? Conditionally defining methods? > > class FooBar { > if (PHP_VERSION_ID < 50000) { > public function FooBar() { > $this->__construct(); > } > } > > public function __foobar() { > > } > } > -- [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] Julien.P