Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70535 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64108 invoked from network); 8 Dec 2013 17:04:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Dec 2013 17:04:40 -0000 Authentication-Results: pb1.pair.com header.from=ellison.terry@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ellison.terry@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: ellison.terry@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wg0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:41691] helo=mail-wg0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/E8-01020-5A6A4A25 for ; Sun, 08 Dec 2013 12:04:38 -0500 Received: by mail-wg0-f52.google.com with SMTP id x13so2531907wgg.7 for ; Sun, 08 Dec 2013 09:04:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=HLF3zlsWygGC1g2Y6L4utVMp8WUGCUGIT080JOVmhnM=; b=Wu4OPw/oO76OliVVh2Gxly7QJ3RZhWunYebhjt1bhluU+mahJs2g0K75IsVE+GQ49I +PfJoiNxjSjVg+NH9cW3ZP8KCdWltEVQpVoiI6rxJEZMT3xUcBjxB7CEWEUgQwk4PQep 47er146ngu/FNkNJHagRbanTYUJyJcC8fejvoIEDgkWkYtrSDYAs9UO/irIVVpfl0oB3 U+Gv5WoRExV9swUn46LN9UY4W+qTDggSGIIhuKdIFd556anJ4mvficI5xfM3GSf0EsGr MwjfuVyUpgxzTzGK7SZONbIsZc1O5Yyg2Pe6Zq9y6BtIg/bxr5hTQO2qC0sJhCHDxrFU 3/5g== X-Received: by 10.180.93.8 with SMTP id cq8mr10776160wib.38.1386522275102; Sun, 08 Dec 2013 09:04:35 -0800 (PST) Received: from [192.168.1.91] (host81-152-194-204.range81-152.btcentralplus.com. [81.152.194.204]) by mx.google.com with ESMTPSA id b7sm16651098wiz.8.2013.12.08.09.04.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 09:04:34 -0800 (PST) Message-ID: <52A4A6A1.3080206@gmail.com> Date: Sun, 08 Dec 2013 17:04:33 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: PHP Internals Content-Type: multipart/alternative; boundary="------------040105050805070409090000" Subject: Introducing pragmas into PHP? From: ellison.terry@gmail.com (Terry Ellison) --------------040105050805070409090000 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, We have ongoing debates about the pull between BC behaviour and wanting to tidy up / optimize performance etc. And often BC for bizarre coding practices means that there is a performance penalty for everyone else. A common way of doing this in C etc. is the use of compiler pragmas, but such a change would in itself be not BC and INI parameters are too blunt an instrument here as these are set at runtime or globally as a PER_INI_USER etc. They can't impact the current source being compiled, and they can't be conveniently namespace-specific. I am suggestion the overload of constants of the form PHP_PRAGMA_XXX to define PHP / Zend compiler / executor behaviours. This approach would be BC to 5.3 unless, of course, the application already used PHP_PRAGMA_* constants, in which case we might also need an allow_php_pragmas INI parameter to globally enable/disable their interpretation. As a small example: namespace fred; echo \strlen("DDDD"); generates different . SEND_VAL 'DDDD' DO_FCALL 1 $0 'strlen' and different (slower) opcode if you omit the \ INIT_NS_FCALL_BY_NAME 'strlen' SEND_VAL 'DDDD' DO_FCALL_BY_NAME 1 $0 Whilst most sane projects would have a simple programming standard which basically says "Don't override builtin functions", the odd one might for various reasons allow this. This practice can significantly complicate optimization for performance (see https://bugs.php.net/bug.php?id=64346). I've seen namespace-based project where all builtins have the explicit global \ prefix. IMO, yukkk. So my suggestion is that we allow the programmer to issue a pragma to inform compiler and runtime handling, so in this case for example, namespace fred; const PHP_PRAGMA_ALLOW_OVERRIDE_BUILTINS=false; echo strlen("DDDD"); would define the constant fred\PHP_PRAGMA_ALLOW_OVERRIDE_BUILTINS and also have the desired compile-time and runtime effect. Alternatively the corresponding global constant \PHP_PRAGMA_ALLOW_OVERRIDE_BUILTINS could be set to false and individual namespaces could set the corresponding namespace constant to true. Thoughts and comments? Terry Ellison --------------040105050805070409090000--