From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#35062: [PATCH v3 2/3] constify a bit of xterm.c Date: Fri, 19 Apr 2019 17:31:38 -0700 Organization: UCLA Computer Science Department Message-ID: <1f700b05-16a8-1159-e2e3-61f9699981a1@cs.ucla.edu> References: <20190407021331.948-1-Hi-Angel@yandex.ru> <20190407021331.948-2-Hi-Angel@yandex.ru> <8336mml3s7.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="117804"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cc: 35062@debbugs.gnu.org To: Eli Zaretskii , Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 20 02:32:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hHdvO-000UYV-US for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Apr 2019 02:32:11 +0200 Original-Received: from localhost ([127.0.0.1]:34860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHdvO-0003XD-0L for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Apr 2019 20:32:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHdvH-0003WS-53 for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2019 20:32:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHdvG-0001D3-59 for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2019 20:32:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHdvG-0001Cu-0h for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2019 20:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hHdvF-0005gx-N3 for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2019 20:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Apr 2019 00:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35062 X-GNU-PR-Package: emacs Original-Received: via spool by 35062-submit@debbugs.gnu.org id=B35062.155572030821857 (code B ref 35062); Sat, 20 Apr 2019 00:32:01 +0000 Original-Received: (at 35062) by debbugs.gnu.org; 20 Apr 2019 00:31:48 +0000 Original-Received: from localhost ([127.0.0.1]:45037 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hHdv2-0005gT-1U for submit@debbugs.gnu.org; Fri, 19 Apr 2019 20:31:48 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hHdv0-0005gG-3x for 35062@debbugs.gnu.org; Fri, 19 Apr 2019 20:31:47 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3FF2416179B; Fri, 19 Apr 2019 17:31:40 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jsiSpZ4tEh7j; Fri, 19 Apr 2019 17:31:39 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 70E5C161722; Fri, 19 Apr 2019 17:31:39 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id unrrCefeGqoi; Fri, 19 Apr 2019 17:31:39 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 460B61616C5; Fri, 19 Apr 2019 17:31:39 -0700 (PDT) In-Reply-To: <8336mml3s7.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157877 Archived-At: I'd rather not use 'const' on locals. Let me tell you a story as to why. I once worked with someone who insisted on using the 'register' keyword on every C local variable that was never taken the address of, on the grounds that this meant the reader could easily see that the variable could never be modified indirectly via a pointer and that this made the code easier to read because you didn't need to worry about aliasing. I disagreed then, and still disagree. Saying 'register' nearly all the time clutters up the code, and the cost is not worth the benefit in C. It's pretty easy for a human reader to determine whether a local variable is taken the address of somewher in its function. (If it's hard, then write an Elisp function that will tell you. :-) In hindsight, perhaps C should have been designed so that 'register' was the default for local variables, and that one needed a special word to say "watch out! this variable might have its address taken!"; but the ship has sailed. 'const' is like 'register' in this respect. Putting 'const' nearly everywhere clutters C code. It's pretty easy for a human reader to determine whether a local variable is modified (if it's hard, write an Elisp function :-). In hindsight, perhaps C should have been designed so that 'const' was the default for local variables; but the ship has sailed there too.