Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39590 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14825 invoked from network); 4 Aug 2008 01:07:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2008 01:07:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=moriyoshi@at.wakwak.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=moriyoshi@at.wakwak.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain at.wakwak.com designates 219.103.130.24 as permitted sender) X-PHP-List-Original-Sender: moriyoshi@at.wakwak.com X-Host-Fingerprint: 219.103.130.24 mgdnp1.nw.wakwak.com Received: from [219.103.130.24] ([219.103.130.24:60541] helo=mgdnp1.nw.wakwak.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/4A-50899-A3656984 for ; Sun, 03 Aug 2008 21:07:08 -0400 Received: from vckyb2.nw.wakwak.com (postfix@vckyb2.nw.wakwak.com [211.9.230.145]) by mgdnp1.nw.wakwak.com (8.14.3/8.14.3/2008-07-17) with SMTP id m74171Q5023520; Mon, 4 Aug 2008 10:07:01 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Received: from at.wakwak.com (at.wakwak.com [211.9.230.135]) by vckyb2.nw.wakwak.com (Postfix) with ESMTP id 6173630061; Mon, 4 Aug 2008 10:07:01 +0900 (JST) Received: from [10.6.6.252] (gw1-ns.bioinfo.ttck.keio.ac.jp [131.113.122.81]) (user=moriyoshi mech=CRAM-MD5) by at.wakwak.com (8.14.3/8.14.3/2008-07-15) with ESMTP/inet id m741711d029172; Mon, 4 Aug 2008 10:07:01 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Message-ID: <48965634.9010900@at.wakwak.com> Date: Mon, 04 Aug 2008 10:07:00 +0900 User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Marcus Boerger Cc: Felipe Pena , internals@lists.php.net References: <1217769121.5923.10.camel@pena> <1124407685.20080803184656@marcus-boerger.de> In-Reply-To: <1124407685.20080803184656@marcus-boerger.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Const-correctness From: moriyoshi@at.wakwak.com (Moriyoshi Koizumi) Marcus Boerger wrote: > Overall you do a ton of 'struct * const var' which only means that you are > going to copy the pointer explicitly. Now functions that use a pointer in a > loop and increment it cannot optimize the code anymore and are forced to use > an additional real variable on the stack. So unless you have a very smart > compiler, the result is an increased stack size. Generally speaking I prefer > const on the reight and mid (between *'s) only. But others prefer it to denote > that not even the passed in pointer gets modifed and this sometimes even makes > debugging easier. That's not necessarily true. In contrast to the volatile qualifier, the const qualifier in this context is just a semantic thing. So if your function has a immutable argument variable, it probably gets compiled a procedure that receives the argument in the registers and use it mutatively as long as no side-effects are possible. (of cource how it compiles depends on the target platform) Having that said, I don't think it makes any sense to make pointer variables immutable, while marking the referent immutable greatly reduces tiny errors. Compilers are often smarter in this case. Moriyoshi -- Moriyoshi Koizumi