From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: ptrdiff_t misuse [was :Re: (empty)] Date: Thu, 05 Jul 2012 22:34:59 +0300 Message-ID: <83obnu2e8s.fsf@gnu.org> 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> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1341516916 440 80.91.229.3 (5 Jul 2012 19:35:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jul 2012 19:35:16 +0000 (UTC) Cc: dmantipov@yandex.ru, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: eggert@cs.ucla.edu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 05 21:35:14 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 1SmrpR-0000Ti-Ld for ged-emacs-devel@m.gmane.org; Thu, 05 Jul 2012 21:35:05 +0200 Original-Received: from localhost ([::1]:46700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmrpQ-00033R-Io for ged-emacs-devel@m.gmane.org; Thu, 05 Jul 2012 15:35:04 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmrpN-00031u-7r for emacs-devel@gnu.org; Thu, 05 Jul 2012 15:35:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmrpL-0005as-Hp for emacs-devel@gnu.org; Thu, 05 Jul 2012 15:35:00 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:33372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmrpL-0005aA-9T for emacs-devel@gnu.org; Thu, 05 Jul 2012 15:34:59 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M6P00200D0BIN00@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Thu, 05 Jul 2012 22:34:56 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M6P002N4D282SA0@a-mtaout20.012.net.il>; Thu, 05 Jul 2012 22:34:56 +0300 (IDT) In-reply-to: <83vci22mr0.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.166 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:151440 Archived-At: Btw, what's the theory behind using ptrdiff_t in preference to EMACS_INT to store values that came from Lisp? E.g., in this snippet: static Lisp_Object set_window_hscroll (struct window *w, EMACS_INT hscroll) { ... ptrdiff_t hscroll_max = min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX); ptrdiff_t new_hscroll = clip_to_bounds (0, hscroll, hscroll_max); Won't this do The Wrong Thing when Emacs is configured with wide ints? It looks like EMACS_INT is always preferable in these contexts, as it always has the right width. Likewise for variables that store buffer or string positions. What am I missing?