[net.lang.c] Read-only Strings

chris@umcp-cs.UUCP (Chris Torek) (11/03/84)

Another good(?) reason for readonly strings is that then the compiler
could use the same address for "equal" strings; that is, if I write

	printf("%d\n", x);
	.
	.
	.
	printf("%d\n", y);

the compiler might produce

		.data
	L21:	.asciz	"%d\n"
		.text
		pushl	x	# well not really but...
		pushal	L21
		calls	$2,printf
		.
		.
		.
		pushl	y
		pushal	L21
		calls	$2,printf

Many FORTRAN compilers use similar tricks when passing constants to
subroutines or functions...  I think I once used the "modify-the-constant"
trick to change the WRITE unit number, just for fun.
-- 
(This mind accidently left blank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland