🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #69

Re: Optimization by programmers

#69
From: Dan Cross
Date: Mon, 12 Oct 2026 21:10
50 lines
2805 bytes
In article <1791830400-5857@newsgrouper.org>,
MitchAlsup  <user5857@newsgrouper.org.invalid> wrote:
>quadibloc@invalid.com (John Savard) posted:
>> On Mon, 12 Oct 2026 11:25:32 -0000 (UTC), Thomas Koenig
>> <tkoenig@netcologne.de> wrote:
>> >David Brown <david.brown@hesbynett.no> schrieb:
>> >> But if you receive a "pointer to const" parameter to a function, you can 
>> >> still write via a cast version of the pointer if the original object was 
>> >> not defined as "const".  (So objects defined as "const" may be placed in 
>> >> read-only memory of some kind, and trying to change them might cause a 
>> >> crash, signal, bus-error, etc.)
>> >
>> >In FORTRAN, it used to be possible on systems such as /360 to write
>> >
>> >      CALL FOO(21)
>> >      WRITE (*,*) 21
>> >      END
>> >
>> >      SUBROUTINE FOO(N)
>> >      N = 42
>> >      END
>> >
>> >and get a printout of 42 (21 is only half the truth,
>> >remember!) because the compiler put the constants in read/write
>> >storage and arguments were passed via address.
>> 
>> And the proper way to correct this error is obvious. Not by putting
>> constants in a segment marked read-only. But in properly implementing
>> language semantics.
>> 
>> So the values of constants are stored in memory.
>> 
>> However, when a constant is passed to a function as an argument,
>> clearly that constant should be treated as an *expression*, not as a
>> variable. So you copy it to a temporary, and pass the address of the
>> temporary to the function.
>
>And you think the language designers in 1956 could have figured that out ???

I don't think that's the right framing.

>>                           Not doing that was the bug.
>
>Some would disagree.

That it's a bug?  Clearly, changing the value of some constant
is surprising, at best.

	- Dan C.
Technical Details
Message-ID: <11ajic7$dq$1@reader2.panix.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
References: <1177fdi$26ea4$1@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <6acd0635.21804140@news.eternal-september.org> <1791830400-5857@newsgrouper.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.arch
Subject: Re: Optimization by programmers
Date: Mon, 12 Oct 2026 21:10:31 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <11ajic7$dq$1@reader2.panix.com>
References: <1177fdi$26ea4$1@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <6acd0635.21804140@news.eternal-september.org> <1791830400-5857@newsgrouper.org>
Injection-Date: Mon, 12 Oct 2026 21:10:31 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="442"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)