Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70538 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70240 invoked from network); 8 Dec 2013 18:12:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Dec 2013 18:12:45 -0000 Authentication-Results: pb1.pair.com header.from=felipensp@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=felipensp@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.178 as permitted sender) X-PHP-List-Original-Sender: felipensp@gmail.com X-Host-Fingerprint: 209.85.216.178 mail-qc0-f178.google.com Received: from [209.85.216.178] ([209.85.216.178:52589] helo=mail-qc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/1A-01020-C96B4A25 for ; Sun, 08 Dec 2013 13:12:45 -0500 Received: by mail-qc0-f178.google.com with SMTP id i17so1994151qcy.23 for ; Sun, 08 Dec 2013 10:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Eb3vOMmRLV9vA1a8FCBk33TBBkwbloFmrf0xxB84rgY=; b=IODJggT7BmxNNUVZBiwdWa3uszsBM3+7gPCfREDvAo3KNY/mF8H4me3vlGxt02BQOg dnlKuvJu8UxqCc69tMdxGIYpggf6U5943qqhF1TlgbVqUoZJ3AGvq8fbP5zkxOgeXsSs hlR0e6qw1Xls8Yb6vq8JFsKCUYGCeqD6k7iCniOKhgVWIidp6Jz1gq6mvkTGG6rO+oB3 RBq4jHNMHzmBcWCMkjVOuSG7ZIDmNGETSrgonaNxx27HmNbzf6CrE/dgVYKWghiAKzpQ 0KefJRvQ3KOMvokmM0dVfNDZnvh5BFLxX8+Zn/Hgrf9BzSrNxCYFltATgipPZdjIOb3e TaMQ== X-Received: by 10.49.75.10 with SMTP id y10mr27127357qev.56.1386526361746; Sun, 08 Dec 2013 10:12:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.12.1 with HTTP; Sun, 8 Dec 2013 10:12:21 -0800 (PST) In-Reply-To: <52A4B578.8060704@gmail.com> References: <52A4A6A1.3080206@gmail.com> <52A4A8DD.60106@gmail.com> <52A4B578.8060704@gmail.com> Date: Sun, 8 Dec 2013 16:12:21 -0200 Message-ID: To: Terry Ellison Cc: Alexey Zakhlestin , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Introducing pragmas into PHP? From: felipensp@gmail.com (Felipe Pena) Hello, On Sun, Dec 8, 2013 at 4:07 PM, Terry Ellison wrote: > On 08/12/13 17:14, Alexey Zakhlestin wrote: >>> >>> 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. >> >> we already have declare() for this purpose exactly. >> http://docs.php.net/declare >> >> it might make sense to use it for more things > > Alexey, perhaps you missed the subtlety of my example: > > > namespace fred; > const PHP_PRAGMA_ALLOW_OVERRIDE_BUILTINS=false; > echo strlen("DDDD"); > > define() is a runtime function implemented by > Zend/zend_builtin_functions.c:ZEND_FUNCTION(define). The constant which is > defines is not available until the DO_FCALL_BY_NAME opcode is itself > executed sometime *after* the compile of the current source completes. > > const is a syntactic construct that can be intercepted in zend_compile.c, > etc., and therefore can condition the remainder of the compile of that > source. That's what pragmas do. > > However, you are quite correct that: > > define('fred\PHP_PRAGMA_ALLOW_OVERRIDE_BUILTINS', false); > include "some_other_php_file_in_namespace_fred.php"; > ... > > would set the pragma for subsequent source scripts in the "fred" namespace, > if we adopted this convention. > > Hope this helps. Terry Looks like you misread Alexey's post. He was talking about declare construct, not define() function. -- Regards, Felipe Pena