From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: get-byte Date: Mon, 10 Nov 2008 14:02:32 +0900 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1226293387 13868 80.91.229.12 (10 Nov 2008 05:03:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Nov 2008 05:03:07 +0000 (UTC) Cc: eliz@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 10 06:04:08 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KzOwM-0003un-Nx for ged-emacs-devel@m.gmane.org; Mon, 10 Nov 2008 06:03:54 +0100 Original-Received: from localhost ([127.0.0.1]:46576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzOvF-0000wG-4C for ged-emacs-devel@m.gmane.org; Mon, 10 Nov 2008 00:02:45 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KzOvA-0000uP-NU for emacs-devel@gnu.org; Mon, 10 Nov 2008 00:02:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KzOv9-0000uD-Dj for emacs-devel@gnu.org; Mon, 10 Nov 2008 00:02:40 -0500 Original-Received: from [199.232.76.173] (port=56605 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzOv9-0000uA-8k for emacs-devel@gnu.org; Mon, 10 Nov 2008 00:02:39 -0500 Original-Received: from mx1.aist.go.jp ([150.29.246.133]:48058) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KzOv6-0005xu-MV; Mon, 10 Nov 2008 00:02:37 -0500 Original-Received: from rqsmtp1.aist.go.jp (rqsmtp1.aist.go.jp [150.29.254.115]) by mx1.aist.go.jp with ESMTP id mAA52X5B007947; Mon, 10 Nov 2008 14:02:33 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp3.aist.go.jp by rqsmtp1.aist.go.jp with ESMTP id mAA52Xad009597; Mon, 10 Nov 2008 14:02:33 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp3.aist.go.jp with ESMTP id mAA52WYm011998; Mon, 10 Nov 2008 14:02:32 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.69) (envelope-from ) id 1KzOv2-0004Kw-Qc; Mon, 10 Nov 2008 14:02:32 +0900 In-reply-to: (message from Stefan Monnier on Sun, 09 Nov 2008 22:30:16 -0500) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-operating-system: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:105527 Archived-At: In article , Stefan Monnier writes: > I'm not opposed to `get-byte' being implemented in C. I just think it > should be implementable as > (defun get-byte (&optional pos string) > (let ((ch (if string (aref string (or pos 0)) > (char-after pos)))) > (or (encode-char ch 'binary) > (error "Not an ASCII nor an 8-bit character: %d" ch)))) `binary' is not a character set, and even if you change it to `eight-bit', it can't be used for unibyte buffer/string because, for instance, (encode-char 128 'eight-bit) is nil. Or, are you proposing to create `binary' charset to make the above work? > Given that, in most cases where you'd use get-byte you could replace it > with either (encode-char (char-after POS) 'binary) > or (encode-char (aref STRING POS) 'binary). It may still be > significantly slower than a direct C implementation of get-byte, but it > is the right functionality to provide (i.e. get-byte is only there for > optimization purposes) and in some cases get-byte is not an option > (e.g. in cases such as (mapcar (lambda (c) (... (encode-char c 'binary) > ..)) )). Do you have a concrete example in which you need some result as a list? I think, most of the case, we don't need such a list, and thus we can have this version: (dotimes (i (length )) (... (get-byte i string) ...)) --- Kenichi Handa handa@ni.aist.go.jp