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,803df5f3f60558d5 X-Google-Attributes: gid103376,public From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson) Subject: Re: Uninitialized "out" parameters Date: 1996/07/21 Message-ID: <4stagp$3vg@mulga.cs.mu.OZ.AU>#1/1 X-Deja-AN: 169207078 references: <31EEACDA.64880EEB@sage.inel.gov> <4sq614$kai@mulga.cs.mu.OZ.AU> organization: Comp Sci, University of Melbourne newsgroups: comp.lang.ada Date: 1996-07-21T00:00:00+00:00 List-Id: dewar@cs.nyu.edu (Robert Dewar) writes: >Fergus said > >"No, certainly it is possible. There are languages in which any code >that might attempt to use an uninitialized variable is a compile-time >error. It would certainly be possible for an Ada compiler to give >warnings in all cases where a variable might be used before it was >initialized." > >Well it depends what you mean. If we read what you say literally, it is >obviously incorrect, since it requires the halting problem to be solved: No, if you read it literally, it's correct -- but you're not reading it literally, you're reading into it more than what I wrote. >If you don't mind getting bogus warnings, i.e. warnings that might be >false, then your statement is trivially true, Yes. I never said anything about not getting some spurious warnings (or spurious errors). Presuming the spurious warnings/errors don't occur often, and so long as there are easy work-arounds when they do occur, I don't think that would be a major problem. Certainly programmers have demonstrated a willingness to accept that sort of thing in other aspect of programming languages (e.g. type systems). > procedure x is > m,n : integer; > begin > (big chunk of code not referencing m,n) > m := n; > end; > >this code references the uninitialized variable n if and only if the big >chunk of code halts. That's an easy proof. Similarly, in a dynamically typed Ada-like language, the code procedure x is m : integer; n : some_other_type; begin (big chunk of code) m := n; end; causes a run-time type error if and only if the big chunk of code halts. Of course, Ada uses static type checking, rather than dynamic typing; they report some "spurious" type errors such as for the example above. There's no reason why Ada compilers couldn't do the analagous sort of thing for uninitialized variables. -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.