From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?Jan_Dj=C3=A4rv?= Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109864: Fix minor problems found by static checking. Date: Tue, 4 Sep 2012 12:25:49 +0200 Message-ID: <644FCDD6-1590-477B-A0AF-B418446D6FD8@swipnet.se> References: <83392zf7bu.fsf@gnu.org> <504506E8.5070506@cs.ucla.edu> <83r4qieszx.fsf@gnu.org> <25F1A420-CE2F-432B-BDE3-3E973E1B2CC3@swipnet.se> <50459584.8020209@cs.ucla.edu> <5045C2CB.90506@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1346754377 8763 80.91.229.3 (4 Sep 2012 10:26:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Sep 2012 10:26:17 +0000 (UTC) Cc: "emacs-devel@gnu.org" To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 04 12:26:19 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T8qKo-0000dJ-Ea for ged-emacs-devel@m.gmane.org; Tue, 04 Sep 2012 12:26:18 +0200 Original-Received: from localhost ([::1]:41102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8qKl-0007eU-E6 for ged-emacs-devel@m.gmane.org; Tue, 04 Sep 2012 06:26:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8qKd-0007eJ-Fh for emacs-devel@gnu.org; Tue, 04 Sep 2012 06:26:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8qKW-0000e9-As for emacs-devel@gnu.org; Tue, 04 Sep 2012 06:26:07 -0400 Original-Received: from mailout.attendit.se ([83.140.103.4]:51995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8qKW-0000db-0Q for emacs-devel@gnu.org; Tue, 04 Sep 2012 06:26:00 -0400 Original-Received: from mail01.melmac.se (mail01.melmac.se [62.20.26.80]) by mailout.attendit.se (Postfix) with ESMTP id 4F54B50093 for ; Tue, 4 Sep 2012 12:20:10 +0200 (CEST) Original-Received: (qmail 9194 invoked by uid 89); 4 Sep 2012 10:25:34 -0000 Original-Received: from h-46-59-42-18.na.cust.bahnhof.se (HELO coolsville.localdomain) (boel.djarv@bdtv.se@46.59.42.18) by mail01.melmac.se with ESMTPA; 4 Sep 2012 10:25:34 -0000 Original-Received: from [172.16.2.213] (gw01.ismobile.com [212.73.186.202]) by coolsville.localdomain (Postfix) with ESMTPSA id 015167FA05E; Tue, 4 Sep 2012 12:25:55 +0200 (CEST) In-Reply-To: <5045C2CB.90506@cs.ucla.edu> X-Mailer: iPhone Mail (9B206) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 83.140.103.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152986 Archived-At: Hello. 4 sep 2012 kl. 10:58 skrev Paul Eggert : > On 09/04/2012 01:31 AM, Jan Dj=C3=A4rv wrote: >=20 >> Given that Emacs have quite a lot of functions that are more than a >> couple of hundred lines long, it is not typically easy. For smaller >> functions, it can be, but small functions sometimes becomes big. >=20 > No doubt our styles differ, but I don't find it that hard. >=20 > For example, on my screen right now I have lib/mktime.c. It has a > function __mktime_internal that is a couple of hundred lines long. As > I understand it, you're proposing that almost all of its dozens of > local variables should be decorated with 'const'. That is, something > like this: >=20 > int min =3D tp->tm_min; > int hour =3D tp->tm_hour; > int mday =3D tp->tm_mday; > int mon =3D tp->tm_mon; > int year_requested =3D tp->tm_year; > int isdst =3D tp->tm_isdst; >=20 > would be changed to something like this: >=20 > const int min =3D tp->tm_min; > const int hour =3D tp->tm_hour; > const int mday =3D tp->tm_mday; > const int mon =3D tp->tm_mon; > const int year_requested =3D tp->tm_year; > const int isdst =3D tp->tm_isdst; >=20 > I dunno. To me those 'const's would take up valuable screen real > estate, and they would slow me down when I read the code, and it's > really not worth the trouble. Unless you have very narrow frames, this does not take up more screen estate= , just whitespace estate. If some variable is not const and then a pointer to it is passed into anothe= r function, you have to lookup that also. Or find the documentation if the s= ource is not close by. > If I want to know whether mday is > modified later, I can just search for 'mday'; that's fast. And in the > typical case where I'm not interested in that particular detail, the > 'const's would be wasting my time. I read "const X" as fast as "X". I mostly program in C++, I guess const is m= ore used there. Jan D.=