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: Proposal: immediate strings Date: Tue, 05 Jun 2012 23:41:19 -0700 Organization: UCLA Computer Science Department Message-ID: <4FCEFB8F.8080106@cs.ucla.edu> References: <4FBB51E7.6080601@yandex.ru> <4FC472E6.5020005@yandex.ru> <4FC47CE1.6050901@cs.ucla.edu> <4FC4D025.9020608@yandex.ru> <4FC4EA10.702@cs.ucla.edu> <4FC739B4.30408@yandex.ru> <4FC79DAD.5040904@cs.ucla.edu> <4FCEF52E.9090801@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1338964898 14366 80.91.229.3 (6 Jun 2012 06:41:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Jun 2012 06:41:38 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 06 08:41:35 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 1Sc9vu-000125-DX for ged-emacs-devel@m.gmane.org; Wed, 06 Jun 2012 08:41:30 +0200 Original-Received: from localhost ([::1]:60356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc9vu-00077D-7t for ged-emacs-devel@m.gmane.org; Wed, 06 Jun 2012 02:41:30 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc9vq-00071b-Tm for emacs-devel@gnu.org; Wed, 06 Jun 2012 02:41:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc9vk-0003VJ-2A for emacs-devel@gnu.org; Wed, 06 Jun 2012 02:41:26 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:39997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc9vj-0003UF-Qo for emacs-devel@gnu.org; Wed, 06 Jun 2012 02:41:19 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id D332739E800E; Tue, 5 Jun 2012 23:41: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 Ln8ayRjABhvL; Tue, 5 Jun 2012 23:41:17 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 692B139E8006; Tue, 5 Jun 2012 23:41:17 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 In-Reply-To: <4FCEF52E.9090801@yandex.ru> 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:150792 Archived-At: On 06/05/2012 11:14 PM, Dmitry Antipov wrote: > The problem with ptrdiff_t is that it's signed (and has no unsigned version), > and the code assumes that the bitfields are unsigned. OK, but can't we then simply say 'unsigned int foo : N' where N is the proper width? > why ptrdiff_t > (read: signed difference between pointers) is used for size values, although > there is a special type ssize_t (and it's unsigned counterpart size_t)? ssize_t is there mostly for historical reasons; it need not be as wide as size_t (and on some ancient hosts is not). It's best used only when the POSIX API uses it. Generally speaking we prefer signed types in Emacs source code, for several reasons. For example, comparisons work better (you don't get strange results like zero is less than -1). Another example: you can trap signed integer overflow when debugging, and catch some bugs that way. This is why we generally prefer ptrdiff_t to size_t.