From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: ptrdiff_t misuse Date: Fri, 06 Jul 2012 08:56:04 -0700 Organization: UCLA Computer Science Department Message-ID: <4FF70A94.4050700@cs.ucla.edu> References: <83lij66yq9.fsf@gnu.org> <4FEDB953.1010800@yandex.ru> <4FEEA720.2040405@cs.ucla.edu> <4FEEFBAB.6000404@cs.ucla.edu> <4FF3E1D6.1050103@cs.ucla.edu> <83bojv4h13.fsf@gnu.org> <4FF48920.501@cs.ucla.edu> <83vci22mr0.fsf@gnu.org> <83obnu2e8s.fsf@gnu.org> <4FF62C92.8090406@cs.ucla.edu> <83liix2xvp.fsf@gnu.org> <4FF69476.2070701@cs.ucla.edu> <83ipe12s6r.fsf@gnu.org> <8739556vjm.fsf@uwakimon.sk.tsukuba.ac.jp> <83bojt2lwm.fsf@gnu.org> <4FF6FCB0.8080400@cs.ucla.edu> <834npk3nfa.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1341590195 8328 80.91.229.3 (6 Jul 2012 15:56:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Jul 2012 15:56:35 +0000 (UTC) Cc: stephen@xemacs.org, dmantipov@yandex.ru, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 06 17:56:33 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 1SnAtU-0003wf-0C for ged-emacs-devel@m.gmane.org; Fri, 06 Jul 2012 17:56:32 +0200 Original-Received: from localhost ([::1]:48920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnAtT-0007vF-3h for ged-emacs-devel@m.gmane.org; Fri, 06 Jul 2012 11:56:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnAtP-0007uz-Fu for emacs-devel@gnu.org; Fri, 06 Jul 2012 11:56:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SnAtN-0003gr-TG for emacs-devel@gnu.org; Fri, 06 Jul 2012 11:56:27 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:58037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnAtJ-0003eh-4j; Fri, 06 Jul 2012 11:56:21 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4C826A6001D; Fri, 6 Jul 2012 08:56:17 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P6VYEBbyujoq; Fri, 6 Jul 2012 08:56:16 -0700 (PDT) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id B85AAA60001; Fri, 6 Jul 2012 08:56:16 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 In-Reply-To: <834npk3nfa.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.179.128.62 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:151457 Archived-At: On 07/06/2012 08:43 AM, Eli Zaretskii wrote: >> But not every use of ptrdiff_t is for buffer and string positions. >> > Bitmap table sizes, for example. > Do they really need to be large? In some cases yes -- certainly in the memory allocators. Maybe in some cases not, but nobody has taken the time to think about it, and in the meantime ptrdiff_t is safer. Generally speaking, if an object can grow and its size is not limited for other reasons to INT_MAX-or-less, code should not use 'int' to count its size. > What for? they span the same range of values. Yes, that's the point -- if ptrdiff_t and EMACS_POS would span the same range of values, why bother to distinguish the two? Whether a value is a buffer position is usually clearly stated in the variable name.