Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82965 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25567 invoked from network); 17 Feb 2015 14:50:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 14:50:52 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wg0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:56198] helo=mail-wg0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/27-19463-B4553E45 for ; Tue, 17 Feb 2015 09:50:51 -0500 Received: by mail-wg0-f53.google.com with SMTP id a1so19512921wgh.12 for ; Tue, 17 Feb 2015 06:50:48 -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:references :in-reply-to:content-type; bh=l3xYnEUYb4QH90K4CPdsl4azoEighGwXEZr8wPHFYcA=; b=0xrR43M+3UI0NBw1qAd4bcyMu/t3OvjyDrC5Z/AiIqTbT6CGS2HEK4YsOFIvF47zHy tnCJVhOpYd8l+oEjvTt1tEPjEDLk45WEhSMaycF3il0N7h6oDsJhqorYVOrYFTw8gk/Z EFXmh7X0fbZDZrrKMxF7tw4FjJLuend02sVxE9USTmyXmG5ACDKyMpg3CQhPzrc0SxKN NN5pSh80iLmD2vS4+xRMSZW5JWI8FdepVhaGE4Bwb4kmZ1Tt3JbYzlWcIjwu/G3y4iRn O77lLN3wTtj19+bijOVAWU8yOkLfVk5NzaSMkJhWy+ldtoniODFMUEtK535JzIb5aUOJ DbGw== X-Received: by 10.180.211.235 with SMTP id nf11mr54129728wic.52.1424184648276; Tue, 17 Feb 2015 06:50:48 -0800 (PST) Received: from [192.168.0.172] ([62.189.198.114]) by mx.google.com with ESMTPSA id hz9sm27731627wjb.17.2015.02.17.06.50.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Feb 2015 06:50:47 -0800 (PST) Message-ID: <54E3553E.6080608@gmail.com> Date: Tue, 17 Feb 2015 14:50:38 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: PHP internals list References: <54E3439D.30407@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------020103090902070100010407" Subject: Re: [PHP-DEV] [RFC][Discussion] Parser extension API From: rowan.collins@gmail.com (Rowan Collins) --------------020103090902070100010407 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Alexander Lisachenko wrote on 17/02/2015 14:21: > 2015-02-17 16:35 GMT+03:00 Rowan Collins >: > > The other alternative is to go to the other extreme, and have the > extensions scoped to a particular file, more like Perl pragmas. > Dare I say we could use the declare() syntax that everyone seems > to have an irrational hatred of? > > declare(pragma=Example\DbcParserExtension); > > > Ouch ) Don't like this way at all, because extensions should process > all files, even if it's not marked with some hints. What I want to see > is PHP analog of Java bytecode compilers, they can transform an > original source code into specific tokens and provide custom > extensions on top of that. So, I want to choose between php.ini option > and explicit methods. Let's see another opinions. It's interesting that you used the word "extension" there. If the hook can only be registered for in php.ini (and it would need to be PHP_INI_SYSTEM if you want to avoid OpCache needing to vary its cache on different settings) then these are basically extensions which happen to be written in PHP - you install them globally, they execute unconditionally, and they do things which can't be done any other way. In that case, it would maybe make more sense to make this part of the "simplified extension API" discussed in a previous thread, rather than exposing it to userland at all. The only abilities you'd lose are ones which should never be used anyway, e.g. statically registering an extension, then dynamically changing its behaviour at runtime by altering global/static variables. I think the same argument applies to per-file pragmas over per-install settings, as to Dependency Injection over global state - you should be able to reason about each module of code in isolation, reuse it in different combinations, etc, etc. What if you want to use two different DbC extensions on the same server, and they collide with each other? What would the error look like if you failed to install an extension that was required to process your source code as intended? A declare line (or Perl's use, or Python's import) gives a clear point where that requirement is defined. Regards, -- Rowan Collins [IMSoP] --------------020103090902070100010407--