[ I've added Ben to Cc because he AFAIR doesn't read xemacs-beta. ]
"Stephen J. Turnbull" <turnbull(a)sk.tsukuba.ac.jp> writes:
Can somebody give a bunch of examples where using integers as
characters is useful?
I can. Here are four:
(let ((letter ?a))
(while (< letter ?z)
... do something with letter ...
(incf letter)))
;; The above example can be coded more nicely after my changes to
;; translate-region (which see), but we're talking legacy code here.
(defun turn-a-into-b ()
(let ((string (make-string 256 ?\0)))
(dotimes (i 265)
(aset string i i))
(aset string ?a ?b)
(translate-region (point-min) (point-max))))
(defvar foo-legal-chars (mapcar #'int-char
'(... a bunch of numeric values
imported from somewhere ...)))
(defun stupid ()
(let ((number (read-number "Please enter a number: ")))
(message "The character that corresponds to %d is: %c"
number (int-char number))))
I could think of more of such, but I don't really see the point.
Remember that characters have been indistinguishable from characters
within Emacs for *decades*.
For that matter, where they are actually used? Ben said
"backward
compatibility," but I haven't seen this used, and I don't really
know how to grep for it. I have grepped for int-char, int-to-char,
char-int, and char-to-int and they're pretty rare in the core and
package code (2/3 of it) that I have.
The ones without them are even worse because they are implicit. See
my examples.
The only one that I ever use is the C-q hack for inserting
characters by code value at the keyboard, and that could arguably
(and in Japanese invariably is) delegated to an input method which
would know about language environment (and return a true character).
Some of us don't do input methods. But that's beside the point,
because C-q can as well use make-char or whatever.
We already have primitives for efficient case conversion
...which don't work. More about that in a separate message.