Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80371 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89501 invoked from network); 11 Jan 2015 17:08:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2015 17:08:30 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.52 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.215.52 mail-la0-f52.google.com Received: from [209.85.215.52] ([209.85.215.52:65528] helo=mail-la0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/D0-18257-C0EA2B45 for ; Sun, 11 Jan 2015 12:08:30 -0500 Received: by mail-la0-f52.google.com with SMTP id hs14so21532368lab.11 for ; Sun, 11 Jan 2015 09:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=uJxfKPm3lWz5HGZLbdN2NMROpK678QRrGF2+RQIMIzc=; b=H4i7TAqZu5rwRQ9Wz8o4nqGfwDkQcsw2ACVPr+S8KRzPaadCOjr35XyubN1OGR4Aj6 2VCG3IkjkLln3tOk4ww4MqI01UuNw0/LjMMwOrv40POy+0Ul5SDiDa4j/luA5gKkn0Z5 T/ebyMnjsfY7qZPnTN/JW90oF8xkTo3bT0FauwJouzj7sSqx44YBOCdvUDxdc5GM5Nbp vz+3macQEVsizoNilfS4aG97/33viEofGk/qk4GVF5rIfqRI43uFO7BLmOb/Ne7ShAwV q63uDYONiwhNydlJwQo+R25gO2/WnCKYl/nbC/+9YbwgvHmXezYw0MRt/oGI09l5ZSpi sUKw== MIME-Version: 1.0 X-Received: by 10.112.130.34 with SMTP id ob2mr32686036lbb.78.1420996105244; Sun, 11 Jan 2015 09:08:25 -0800 (PST) Received: by 10.112.154.133 with HTTP; Sun, 11 Jan 2015 09:08:25 -0800 (PST) In-Reply-To: References: <54B1AA31.6050703@gmail.com> Date: Sun, 11 Jan 2015 09:08:25 -0800 Message-ID: To: Sara Golemon Cc: Stanislav Malyshev , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] One API to rule them all? (Was: Extension Prepend Files) From: pierre.php@gmail.com (Pierre Joye) On Sun, Jan 11, 2015 at 8:40 AM, Sara Golemon wrote: > On Sat, Jan 10, 2015 at 11:18 PM, Pierre Joye wrote: >> More than adding a new layer, I would love to see something similar to >> hhvm or Zephir available by default. If C is used, then only the >> relevant parts have to be implement by the developers, skipping all >> the over complicated data mangling, swapping, exchange, etc between >> userland and the engine. It is then relatively easy to end up >> generating codes for either php, hhvm or any other platform. Using >> builtin script (yes, in this case it could be a nice thing), it could >> became a very nice way to develop php&co extensions. >> > And this is one of the things I love about HHVM's current extension > API, so yeah I'd like to bring some elements of that in if possible. > At one extreme it means changes to the lexer/parser, and the other end > it might mean a combination of prepend files (which are pure PHP) and > either an interface-definition file (simplified version of PHP) or > something like PHP's current API "inject a function/method here, and > here's the signature". I imagine this being one of the longer > portions of our discussions since a lot of folks are going to have > opinions on what approach is better. I have a working proof of concept using something like: ---- native void foo() { printf("Hello from native!"); } ?> Need a refactoring and some sanity checks but the concept works. It indeed relies on my patch to bundle the concatenated PHP scripts sections as the builtin script, generating .c files from the other parts as well as the config.* and other files. Ideally I like to include that in pickle, so one can package a release from the PHP files/repo to generate the resulting extension package. I will continue later this week and push it to github as soon as I have a very draft working version for someone else than me :) >> For what I can imagine (I did not remotely try to implement it yet) is >> to find a way to parse, say, a php script which include custom >> sections for C (or C++) codes. We could use comments but I do not like >> the idea, mainly because it will be tricky to have editors support :) >> > That's ambitious, but not impossible. :) I worked around that for now, could even work with 5.x if we expose (internally) zend_execute_string :) >> One problem, I do not think it is possible to customize the current >> lexer to allow that on demand, but it could be possible using a more >> modern lexer tools. I am not sure how flexible the hhvm lexer is or if >> we should have yet another language (as I would rather use plain PHP >> in this case, even if it makes the task slightly harder to implement >> or generate slightly bigger native code due to type checking or >> conversions). >> > PHP as the greatest-common-denominator makes sense to me too. Much as > I like the flexibility of user attributes in HHVM, the goal of this > API layer is to be engine agnostic, so syntax should fall into > php-langspec, deviating as little as possible. Full ack. Cheers, -- Pierre @pierrejoye | http://www.libgd.org