🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #72

Re: Optimization by programmers

#72
From: MitchAlsup
Date: Mon, 12 Oct 2026 22:37
56 lines
3089 bytes
cross@spitfire.i.gajendra.net (Dan Cross) posted:

> 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.

Allows one to have 1 {sin(), cos() ...} subroutine and change the value of pi
so one then has {sinpi(), cospi(), ...}
> 
> 	- Dan C.
> 
Technical Details
Message-ID: <1791844654-5857@newsgrouper.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!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> <11ajic7$dq$1@reader2.panix.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
From: MitchAlsup <user5857@newsgrouper.org.invalid>
Newsgroups: comp.arch
Subject: Re: Optimization by programmers
References: <1177fdi$26ea4$1@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <6acd0635.21804140@news.eternal-september.org> <1791830400-5857@newsgrouper.org> <11ajic7$dq$1@reader2.panix.com>
Date: Mon, 12 Oct 2026 22:37:34 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1791844654-5857@newsgrouper.org>
Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857
Injection-Date: Mon, 12 Oct 2026 22:37:34 GMT
User-Agent: Newsgrouper/0.9.0