Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79001 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47977 invoked from network); 19 Nov 2014 15:10:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2014 15:10:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 198.187.29.245 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 198.187.29.245 imap11-3.ox.privateemail.com Received: from [198.187.29.245] ([198.187.29.245:46344] helo=imap11-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/C5-15892-8E2BC645 for ; Wed, 19 Nov 2014 10:10:32 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id EC3678800F7; Wed, 19 Nov 2014 10:10:29 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id zNEhUdrAAqOr; Wed, 19 Nov 2014 10:10:29 -0500 (EST) Received: from oa-res-27-29.wireless.abdn.ac.uk (oa-res-27-29.wireless.abdn.ac.uk [137.50.27.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 6659F8800F6; Wed, 19 Nov 2014 10:10:28 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <20141119150713.GY2294@phcomp.co.uk> Date: Wed, 19 Nov 2014 15:10:27 +0000 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <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> To: Alain Williams X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Remove PHP 4 Constructors From: ajf@ajf.me (Andrea Faulds) > On 19 Nov 2014, at 15:07, Alain Williams wrote: >=20 > 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: >=20 > It would be nice to be able to do something like: >=20 > try { > .... >=20 > # if PHP_VERSION_ID > 50500 > } catch(PDOException $e) { > .... > } finally { > ... tidy up > } > # else > } catch(PDOException $e) { > ... tidy up not quite where I want it > .... > } > # endif >=20 > 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() { =20 } } -- Andrea Faulds http://ajf.me/