Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80428 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59804 invoked from network); 13 Jan 2015 02:02:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2015 02:02:35 -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.50 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.215.50 mail-la0-f50.google.com Received: from [209.85.215.50] ([209.85.215.50:63125] helo=mail-la0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/31-51796-9BC74B45 for ; Mon, 12 Jan 2015 21:02:34 -0500 Received: by mail-la0-f50.google.com with SMTP id pn19so287347lab.9 for ; Mon, 12 Jan 2015 18:02:30 -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:content-transfer-encoding; bh=k0KmsldGfFqscN9XaX9zTWj6LaWhgjwK5uq1E1xGTgw=; b=l/ns4AsboFqaP3uN/aWIK275Wq4er0QZNVeJPKhqMHdbZrIMaqJlZrHBIGu3hSBCP8 RSUiG56TqvwkITuUDZZB2rsWpsAgwxy4S1t6vjOtWjFMIEnnlZRaNYUI7o4A8ubDRNs2 V0vt/7ib0+5s/K6kp4EfBXvusAUV6JTiIAioyJDBybWmKmDgI6pLOM2bkctyzBDNJzQf 4ALM9m4Gdx33rWRQLJuzt0t9SmZfkFU/SSUzdsjEBac8PxJ82bHQNlpCTz1OWIZUV/GE K9eQJUlJruZ6QRMbFlI7zPq3hn0toe+sxaYQEiOu4JDOZv9bjcGQJpuinW2ElxmDtcpu pUTg== MIME-Version: 1.0 X-Received: by 10.112.167.136 with SMTP id zo8mr40232164lbb.17.1421114550487; Mon, 12 Jan 2015 18:02:30 -0800 (PST) Received: by 10.112.154.133 with HTTP; Mon, 12 Jan 2015 18:02:30 -0800 (PST) In-Reply-To: References: <54B1AA31.6050703@gmail.com> <003901d02de5$53732480$fa596d80$@tekwire.net> <005a01d02e1a$02d27a00$08776e00$@tekwire.net> <008f01d02e67$6e92ad80$4bb80880$@tekwire.net> Date: Mon, 12 Jan 2015 18:02:30 -0800 Message-ID: To: Sara Golemon Cc: =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= , Stanislav Malyshev , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] One API to rule them all? (Was: Extension Prepend Files) From: pierre.php@gmail.com (Pierre Joye) On Mon, Jan 12, 2015 at 9:29 AM, Sara Golemon wrote: > On Mon, Jan 12, 2015 at 4:58 AM, Fran=C3=A7ois Laupretre > wrote: >> I am not crazy about it either, I just want to generate code for >> argument parsing (removing every access to zval, dealing with >> 'mixed' type, checks...), return value (convert to zval, maybe a >> pair of checks), and the global 'glue' code (global header file, >> function/constant declare/undeclare, all the boring stuff). >> Some of this is too complex for C macros. The rest is provided >> by the user in C and stays in C. This code will use C macros to >> access what we want to abstract. >> > Okay, but why even generate code for argument parsing? Why not just > pass the arguments/return-values as their concrete type? > > For the record, I'm with you on not having anyone access zvals > directly, or having them deal with zpp, but that doesn't necessitate > generated code. > >> PHP is fine but defining a tree of metadata in json or yaml is >> really easier than writing nested array statements. >> > Could you explain what you mean by this? I'm not sure where nested > arrays come from. > > For example, the PHP code could be something as simple as the > following (but see below, I don't think this is necessarily a good > idea): > > function NATIVE_STRING_foo(int $bar, float $baz =3D 3.14) {} > > Although scalar type hints aren't supported, we can actually fake them > in the parser letting them look like class type hints, then converting > them post-parse. Meanwhile, a function with an empty body named > "NATIVE_T_*()" indicates its a stub, and what type it returns. Ugly, > yes. But compatible with all PHP parsers 5 and later. > > Then in the C/C++ side, we present: > > php_string foo(int bar, double baz) { > /* Normal(ish) C code goes here */ > } I must be something but I do not know how it can be exposed to userland like that without the execute_data part. By the way, we may finally have a good usage for the new args macros ;) > All that said, I think we can do better than fake typehints and a > kludgy return type, but my point is that we don't need to invent a new > format just to declare functions since we had this nice language > called PHP which already knows what PHP functions look like. Yes, only not sure we can do it for 5.x and 7.x. I mean the native parts, if we manage to provide new APIs (maybe backport could be allowed or via an "extension" that simply gets bundled). Cheers, --=20 Pierre @pierrejoye | http://www.libgd.org