Jan Vroonhof <vroonhof(a)math.ethz.ch> writes:
Hrvoje Niksic <hniksic(a)iskon.hr> 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)))
If only everybody used incf. I think it could make sense to make
incf and < work with characters (and not convert them to int).
(incf foo) is exactly equivalent to (setf foo (1+ foo)). If you don't
get my drift, try to imagine what (incf (car letters)) does. The
point is, incf is a macro, and it doesn't know at compile-time whether
the symbol will hold characters or numbers at run-time.
If you want magic, build it into 1+. But I think I'd be against it.
Things get tricky with
(+ ?a 1) ;; Return char
(+ ?a ?z) ;; Signal error?
How about (+ 1 ?a)? And (+ 1 2 3 ?b)? It'd have to be *way* too much
magic.