Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0004/charcode.tty
There are no other files named charcode.tty in the archive.

The facilities in this file make it possible to gain the efficiency
that comes from dealing with character codes instead of character atoms
without losing the symbolic advantages of the latter.

Two functions (with appropriate macros, etc.) are provided:

charcode[c]  Nlambda that returns the character code structure specified
	by c.  If c is a 1-character atom or string, the corresponding character
	code is simply returned.  Thus (CHARCODE A) is 65, (CHARCODE 0) is 48.
	If c is a list structure, the value is an image of c with all the
	leaves replaced by the corresponding character codes.  E.g.,
	(CHARCODE (A (B C))) is (65 (66 67)).

	charcode permits easy specification of certain peculiar character
	  A multi-character atom or string whose first character is ^ is
	  interpreted as the control-character equivalent of the character
	  denoted by its remaining characters.  Thus, (CHARCODE ^A) is 1,
	  the code for control-A.

	  A multi-character atom or string whose first character is # is
	  interpreted as the meta-character equivalent of the character
	  denoted by its remaining characters (= that character code + 128).
	  Thus, (CHARCODE #^A) is 129, the code for meta-control-A.

	  The following key words are mapped into the indicated codes:
		CR	13
		LF	10
		SPACE or SP	32
		EOL	13 (= CR) for Interlisp-D, 31 (= TENEXEOL) for
			    other system types
		FF 	17 (form feed)
		ESCAPE or ESC	27
		BELL	7
		BS	8
		TAB 	9
		NULL	0
		DEL	127

	Finally, charcode maps NIL into NIL.  This is included because
	some character-code producing functions sometimes return NIL
	(e.g. NTHCHARCODE); a test for that value can be included
	in a charcode list along with true character-code values.

Charcode of symbolic arguments can be used wherever a structure of
character codes would be appropriate.  For example

There is a macro for charcode which causes the character-code structure
to be constructed at compile-time.  Thus, the compiled code for these
examples is exactly as efficient as the less readable
	(FMEMB (NTHCHARCODE X 1) (QUOTE (13 10 32)))
	(EQ (BIN FOO) 3)

The second function in this file is a selection function similar to
SELECTQ, except that the selection keys are determined by applying
charcode (instead of QUOTE) to the key-expressions:

selcharq[e;clause1...clausen;default]  Nlambda like selectq.  If the value of
	e is a character code or NIL and it is EQ or MEMB to the result
	of applying charcode to the first element of a clause, the remaining
	forms of that clause are evaluated.  Otherwise, the default is evaluated.
		  ((SPACE TAB) (FUM))
		  ((^D NIL) (BAR))
		  (a (BAZ))
is exactly equivalent to
		  ((32 9) (FUM))
		  ((4 NIL) (BAR))
		  (97 (BAZ))

Furthermore, selcharq has a macro such that it always compiles as
an equivalent selectq.

Comments and suggestions to Ron Kaplan