Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2013 invoked from network); 26 May 2014 09:02:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2014 09:02:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:54841] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4B/D6-60353-23303835 for ; Mon, 26 May 2014 05:02:44 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id D59BD200095; Mon, 26 May 2014 05:02:39 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap1.ox.registrar-servers.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id wQbwxqEbZYr2; Mon, 26 May 2014 05:02:39 -0400 (EDT) Received: from [192.168.0.200] (unknown [90.203.28.11]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id B5F3D200083; Mon, 26 May 2014 05:02:34 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) In-Reply-To: Date: Mon, 26 May 2014 10:02:30 +0100 Cc: Zeev Suraski , Xinchen Hui , PHP Internals , Bob Weinand , Stas Malyshev , Andi Gutmans , Nikita Popov Content-Transfer-Encoding: quoted-printable Message-ID: References: <-6285448086228171932@unknownmsgid> <67d97efff27b61e45ef74d4f4339b4b3@mail.gmail.com> <962B3020-200F-45D2-8FEC-AD7A0BFDA50E@ajf.me> To: Dmitry Stogov X-Mailer: Apple Mail (2.1878.2) Subject: Re: [PHP-DEV] RE: [RFC] Fast Parameter Parsing API From: ajf@ajf.me (Andrea Faulds) On 26 May 2014, at 09:43, Dmitry Stogov wrote: > I more or less like the last option, and actually it's similar to Bob > original proposal. > But I see two disadvantages: > 1) It'll relay on macros with variable arguments and it may be not = portable > across all compilers. > 2) It uses nested macros and it may make a nightmare for finding = source of > some syntax mistake in user code. It could be done without variable arguments, with different syntax. = Actually, I=92m not sure that syntax can be done *with* them based on = how inflexible C99=92s variadic macros are. But the following could work, right? ZEND_PARSE_PARAMETERS(2, 4, ZP_ARRAY(input) ZP_LONG(offset) ZP_OPTIONAL = ZP_ZVAL(z_length) ZP_BOOL(preserve_keys)) The syntax is ugly, though. It looks like it should be a function and = have commas between arguments, but it doesn=92t. You could do something = like this: ZEND_PARSE_PARAMETERS(2, 4, (ZP_ARRAY(input), ZP_LONG(offset), = ZP_OPTIONAL, ZP_ZVAL(z_length), ZP_BOOL(preserve_keys))) That doesn=92t require variadic macros as it would exploit the way the C = preprocessor works. However, I=92m not sure that=92s actually an = improvement, especially because the ZP_* macros would now look horrible, = having to contain garbage at the beginning and end to cancel out the = comma. It=92s arguably uglier than the one above it. If we go for the =93Simpler Variation=94 proposal and don=92t specify = counts, then this is feasible: ZEND_PARSE_PARAMETERS((ZP_ARRAY(input), ZP_LONG(offset), ZP_OPTIONAL, = ZP_ZVAL(z_length), ZP_BOOL(preserve_keys))) But again, the doubly-nested () syntax is ugly and probably confusing. = I=92d rather go with the first option, even if it does look a little too = much like a function. With the =93Simpler Variation=94 proposal, it = could even look like this: ZEND_PARSE_PARAMETERS(ZP_ARRAY(input) ZP_LONG(offset) ZP_OPTIONAL = ZP_ZVAL(z_length) ZP_BOOL(preserve_keys)) Doesn=92t that look nice? :) -- Andrea Faulds http://ajf.me/