From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ed86965848f8610b X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: Reading environment variables in ADA? Date: 1998/10/13 Message-ID: #1/1 X-Deja-AN: 400873984 X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 References: <6tdl75$qs6$2@nyheter.chalmers.se> <6vdgvv$2h3$1@nnrp1.dejanews.com> <6vfgvo$ja0$1@nnrp1.dejanews.com> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 908341294 nnrp-09:27350 NO-IDENT pogner.demon.co.uk:158.152.70.98 Organization: At Home Newsgroups: comp.lang.ada Date: 1998-10-13T00:00:00+00:00 List-Id: eachus@spectre.mitre.org (Robert I. Eachus) writes: > In article <6vfgvo$ja0$1@nnrp1.dejanews.com> dewarr@my-dejanews.com writes: > > > I find this a specious argument, it would equally well apply to constants > > at the global level which you allowed C to modify, and there is no way of > > generating inefficient code to allow this to "work" whatever that means. > > > A constant is a constant, it cannot be modified after declaration > > time. If you have your C code modify it that is morally equivalent > > to having C destroy your Ada generated code by poking at it. This > > is just plain junk buggy code, and it is absurd to generate > > deliberately suboptimal code so that this particularly bug can be > > got away with! > > Agreed, it is absurd, but it is also, unfortunately, practical > advice, especially in the case of environment variables. (See the > man page from SunOS atttached.) I don't like creating storage leaks, > but the Ada version of putenv I use explicitly allocates heap space > and forgets about it after the return. Much easier than finding the > insidious bugs caused when it is called with a stack or constant > value. [putenv man page snipped] and I recently got bitten by openlog on Solaris for the same reason. However, I certainly don't think that compilers should generate inefficient code because of potential OS/library problems like this, as Robert seemed to say; programmers may have to write inefficient code, of course.