Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87736 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93406 invoked from network); 12 Aug 2015 22:12:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2015 22:12:49 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 216.33.127.80 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 216.33.127.80 mta11.charter.net Solaris 10 1203 Received: from [216.33.127.80] ([216.33.127.80:59027] helo=mta11.charter.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 00/E2-03000-0E4CBC55 for ; Wed, 12 Aug 2015 18:12:49 -0400 Received: from imp11 ([10.20.200.11]) by mta11.charter.net (InterMail vM.8.01.05.09 201-2260-151-124-20120717) with ESMTP id <20150812221246.CBMB5815.mta11.charter.net@imp11>; Wed, 12 Aug 2015 18:12:46 -0400 Received: from mtaout004.msg.strl.va.charter.net ([68.114.190.29]) by imp11 with smtp.charter.net id 3yCm1r0040eWGlw05yCmc3; Wed, 12 Aug 2015 18:12:46 -0400 Received: from impout006 ([68.114.189.21]) by mtaout004.msg.strl.va.charter.net (InterMail vM.9.00.020.01 201-2473-160) with ESMTP id <20150812221246.JOUV1440.mtaout004.msg.strl.va.charter.net@impout006>; Wed, 12 Aug 2015 17:12:46 -0500 Received: from pc1 ([96.35.251.86]) by impout006 with charter.net id 3yCl1r00H1sc0so01yCmob; Wed, 12 Aug 2015 17:12:46 -0500 X-Authority-Analysis: v=2.1 cv=Z7ZiHRhA c=1 sm=1 tr=0 a=Is5gsZaFXO8aPum+t7Tz+g==:117 a=Is5gsZaFXO8aPum+t7Tz+g==:17 a=hOpmn2quAAAA:8 a=BCPeO_TGAAAA:8 a=N659UExz7-8A:10 a=WkVbpKPo-lRzZJOvmtgA:9 a=pILNOxqGKmIA:10 Message-ID: <7736C746A64A480AB3F285609E5DADB5@pc1> To: "PHP Internals" , "Dmitry Stogov" References: <8BE12FDCDC5C457282790368866BD61E@pc1><04E6618E3189404FB15D042E588A90FC@pc1> Date: Wed, 12 Aug 2015 17:12:46 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Subject: Re: [PHP-DEV] Parameter parsing for zval type? From: php_lists@realplain.com ("Matt Wilmas") H Dmitry, ----- Original Message ----- From: "Dmitry Stogov" Sent: Tuesday, August 11, 2015 > On Tue, Aug 11, 2015 at 11:10 PM, Matt Wilmas > wrote: > >> [...] >> >> Look at e.g. is_numeric() or strpos() (needle). Plain zval param >> parsing, >> so NO ZVAL_DEREF() occurs (FAST_ZPP or traditional). These 2 example >> functions don't handle IS_REFERENCE type, so they would break. >> >> Or is there no way for them (or any function?) to get a IS_REFERENCE? >> Then *why* is there ZVAL_DEREF() in param parsing functions? We could >> remove it! >> > > We probably may remove ZVAL_DEREF() for functions arguments passed by > value, but we don't know if argument was passed by value or by reference > in > ZPP functions. Actually, in FAST_ZPP for scalars we may probably assume > passing by value and remove ZVAL_DEREF(), but I'm not sure if this is 100% > safe. Yes, speaking of scalars, I had already noticed that it doesn't make sense to have a "separate" argument for the FAST_ZPP scalar _EX macros, as there's nothing to separate (same with traditional '/') on simple values. I was changing those macros, and don't think they're used anyway. Also, I think those simple/scalar types wouldn't be used with by-reference arguments (?), as there would be nothing to update... Like I said in reply to Nikita, it seems like separating is needed for by-reference args, so only need DEREF if *also* separating? It looks like that was the idea with Z_PARAM_ZVAL_EX(). And for other types, separating only applies to arrays or strings, I believe. As far as not 100% safe, you mean IS_REFERENCE type causing an error about wrong type? Shouldn't that only happen if developer indicated by-ref arg, but then used wrong type in parsing? On the other hand, it seems like always using ZVAL_DEREF() won't hurt anything? e.g. part of my confusion was that I thought IS_REFERENCE was wanting to be *kept* in some cases (after parsing), but it seems to not be the case. :-) Speaking of confusion, it also seems the DEREF stuff is unnecessary in type.c:php_is_type(), for example. > Thanks. Dmitry. Thanks, Matt