[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: get-byte
From: |
Kenichi Handa |
Subject: |
Re: get-byte |
Date: |
Mon, 10 Nov 2008 14:02:32 +0900 |
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) |
In article <address@hidden>, Stefan Monnier <address@hidden> 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)
> ..)) <string>)).
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 <string>))
(... (get-byte i string) ...))
---
Kenichi Handa
address@hidden