Path: utzoo!attcan!uunet!husc6!purdue!decwrl!amdcad!tim From: tim@amdcad.AMD.COM (Tim Olson) Newsgroups: comp.sys.amiga Subject: Re: Leo's ANSI C Flame Message-ID: <22257@amdcad.AMD.COM> Date: 30 Jun 88 01:13:19 GMT References: <8806292138.AA22025@decwrl.dec.com> Reply-To: tim@delirun.amd.com (Tim Olson) Organization: Advanced Micro Devices Lines: 28 Summary: Expires: Sender: Followup-To: In article <8806292138.AA22025@decwrl.dec.com> rmeyers@tle.dec.com (Randy Meyers 381-2743 ZKO2-3/N30) writes: | Kernighan and Ritchie never guaranteed the string constants were modifiable. | It was an accident of early implementations that string constants could | be modified, and a very few programmers came to rely on it (probably | again initially by accident). Note that there is no reason to have | modifiable string constants in the language. Any program that takes | advantage of modifiable string constants can be rewritten to use: Well, K&R say that string constants are type "array of characters", and there is no such read-only restriction on this type. In fact, they went out of their way to allow such manipulation, because they declared that *all* string constants, even when written identically, are distinct. This allows programmers to do things like name = mktemp("tempXXXXXX"); Leo's argument that a compiler that optimized and assigned 16 to x for x = strlen("constant string"); would break if he modified the string at runtime is incorrect, because there is no way to get a legal pointer to the string in the above expression ("constant string" is distinct from any other string constant). -- -- Tim Olson Advanced Micro Devices (tim@delirun.amd.com)