Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27845 invoked from network); 12 Jan 2015 17:29:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2015 17:29:55 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.217.175 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.217.175 mail-lb0-f175.google.com Received: from [209.85.217.175] ([209.85.217.175:63017] helo=mail-lb0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/92-04585-19404B45 for ; Mon, 12 Jan 2015 12:29:54 -0500 Received: by mail-lb0-f175.google.com with SMTP id z11so18827575lbi.6 for ; Mon, 12 Jan 2015 09:29:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=RRkme4lq1zah2TcMTKmttmvIBd5Fgbibw9s1ktDBC0g=; b=Cpoc+pN/5kFCJJyKSu/DRPfEsTgA1vTb6dMw8qOKj6adrL/Oa3NE3l5QhlU/7cMdg5 8ZK0eQ0v/4WQD3czL5WNykFYRP6l33614mOFfQS2cEOxSUQ3KJKaGvpeCoRHZZwQp8IU InLpqh7YLKe7d6UjzwagN4rDxWilqiic2ESxQZr5D4jWtAoSH9IuxSl6TBS40xgPx5TM JF/a1dPOiEk3ymIH8KzXOkPUPUxF8hontlK9zeP44Cq5jxB3En1WriASpndTRcIxnv4a HYNf2SEbfVM0wacyVtehupSA4JZEotcSRDAQScwrlr3uzuUVLKtCGVWIMMUinwCreOd4 e3xQ== X-Gm-Message-State: ALoCoQnOVr/BomAL1pSVvSQmP3VtZPtLHswnRJ1rOa8rfkuKrhA1oFNmmgzpSdzSrnKQj7oxzPE3 MIME-Version: 1.0 X-Received: by 10.152.25.129 with SMTP id c1mr38411948lag.65.1421083790546; Mon, 12 Jan 2015 09:29:50 -0800 (PST) Sender: php@golemon.com Received: by 10.112.171.97 with HTTP; Mon, 12 Jan 2015 09:29:50 -0800 (PST) X-Originating-IP: [199.201.64.2] In-Reply-To: <008f01d02e67$6e92ad80$4bb80880$@tekwire.net> 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 09:29:50 -0800 X-Google-Sender-Auth: wvW98KPVvZXdEuSD0ZOyXq12W1w Message-ID: To: francois@tekwire.net Cc: Pierre Joye , 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: pollita@php.net (Sara Golemon) 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 */ } 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. -Sara