Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87289 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15393 invoked from network); 25 Jul 2015 14:17:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2015 14:17:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:38185] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/60-12869-A5A93B55 for ; Sat, 25 Jul 2015 10:16:59 -0400 Received: by wibxm9 with SMTP id xm9so64932056wib.1 for ; Sat, 25 Jul 2015 07:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=p4/r0hnzz/8cHQoryxySJUYfOGF4UsFfhAIubkiPYoQ=; b=Fy677/l81fkJ3jh3pRXumH9W3EGlC0rajVxD0fWPXJDDkgCYPy5BvShHGHGvZAykm1 1+6eko5TRs/NP1SKmeX66v0cNW/5cJphbZV4lnmxfIXUoWW4cekAG0QUtoSoOXQ6RKzK BxC8uk1ONnYTUxNM3on2HsU+b19dw5t+293bRWkjIOgv/RJRAGr6IIFMIFBTgFp675NX M8xqB5K7NlYmNPF3iCxIPxYUkjg3h0UMjl/7SZahF96xW4oWsPpACIPUelwR9cD5NY4W iL8zJlj6nfwGwyp4o+k1gCLMhzZrCvfVoLA5bwll7QoyP8WyIrfOBN6zovqCPE6aSfft 30+w== X-Received: by 10.194.71.164 with SMTP id w4mr36013099wju.61.1437833815125; Sat, 25 Jul 2015 07:16:55 -0700 (PDT) Received: from [192.168.0.5] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by smtp.googlemail.com with ESMTPSA id u7sm3525407wif.3.2015.07.25.07.16.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jul 2015 07:16:54 -0700 (PDT) To: internals@lists.php.net References: <55B2E975.50607@gmail.com> <55B377D5.8060602@gmx.de> Message-ID: <55B39A54.3030502@gmail.com> Date: Sat, 25 Jul 2015 15:16:52 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55B377D5.8060602@gmx.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Make debug_zval_dump prints int as long From: rowan.collins@gmail.com (Rowan Collins) On 25/07/2015 12:49, Christoph Becker wrote: > I agree that the manual page needs an update, but it seems that would > result in an even more lengthy explanation of the caveats due to the > different behavior under PHP 5 and PHP 7, respectively. Well, the current manual page is invalid for any version of PHP which is currently maintained, since 5.3 is EOL, and 5.4 raises a fatal error for the first example. That actually simplifies things a little bit, because you don't need all the caveats about whether the variable is passed by reference or not, that's can just be a historical footnote. > It seems to me that the basic issue of debug_zval_dump() is that it is a > function and not a language construct, so the refcounts are never "quite > right". Agreed. > The variadic nature of the function may add to the confusion, > see . Oh, lord, I didn't realise that was even possible! > >> For instance, an IS_REFERENCE zval could be shown as such, with a >> separate refcount from the referenced value, so that you could follow >> along with the examples in this blog post: >> http://nikic.github.io/2015/05/05/Internal-value-representation-in-PHP-7-part-1 >> The current implementation just adds 1 to the target refcount, per this >> experiment: http://3v4l.org/NejOM > Apparently, this has been done deliberately for compatibility reasons[1]. > > [1] > > Yeah, I spotted that comment, but compatibility with what, for what end? The refcounts given aren't the same between PHP5 and PHP7, and the current approach completely masks how many variables share an IS_REFERENCE zval, because it only ever increments the count by 1. If we're willing to change "long(42) refcount(1)" to "int(42)", then even the format of the output clearly isn't sacred, so why not throw in as much information as possible? If we're not going to make any attempt at accuracy, then rather than making cosmetic changes like "int" for "long", we should be adding an E_DEPRECATED flag and leaving the function to die quietly. Regards, -- Rowan Collins [IMSoP]