Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!decvax!genrad!mit-eddie!godot!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Read-only Strings Message-ID: <636@umcp-cs.UUCP> Date: Fri, 2-Nov-84 23:06:52 EST Article-I.D.: umcp-cs.636 Posted: Fri Nov 2 23:06:52 1984 Date-Received: Sun, 4-Nov-84 05:01:39 EST References: <9498@watmath.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 33 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