Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: David Brown Newsgroups: comp.compilers Subject: Re: modifying constants in Fortran and elsewhere Date: Mon, 17 Jul 2023 13:09:43 +0200 Organization: Compilers Central Sender: johnl%iecc.com Approved: comp.compilers@iecc.com Message-ID: <23-07-011@comp.compilers> References: <23-07-003@comp.compilers> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="81027"; mail-complaints-to="abuse@iecc.com" Keywords: history, forth Posted-Date: 17 Jul 2023 12:18:48 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <23-07-003@comp.compilers> Xref: csiph.com comp.compilers:3507 On 11/07/2023 04:42, gah4 wrote: > A potential bug since the earliest days of Fortran is passing a > constant to a subroutine, and then changing the value of the dummy > argument. > > In at least some Fortran system, this modifies the value of a constant > used other places in a program. > > As this was known when PL/I was designed, it is defined such that > modifiable constants are passed to called procedures. C avoids it by > not allowing the & operator on constants. (Though K&R allows > modification of string constants.) > > Somehow, in all the years, that feature was never added to Fortran. > > It is easy to write programs and test for it, but I wonder if there > are any stories for real program that had this bug, and even better, > stories about the difficulty of finding it, or problems caused by it. I don't think any language can beat Forth here: 1 . => 1 ok 1 1 + . => 2 ok : 1 2 ; => ok 1 . => 2 ok 1 1 + . => 4 ok If you want to redefine the meaning of a number, you just define it like any other identifier.