From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: Uninitialized "out" parameters
Date: 1996/07/23
Date: 1996-07-23T00:00:00+00:00 [thread overview]
Message-ID: <4t3o3s$kt9@felix.seas.gwu.edu> (raw)
In-Reply-To: 4svba5$j2i@mulga.cs.mu.OZ.AU
In article <4svba5$j2i@mulga.cs.mu.OZ.AU>,
Fergus Henderson <fjh@mundook.cs.mu.OZ.AU> wrote:
>Threads do have a habit of shifting topics. When you started talking
>about what "cannot be", and referred to undecidability to justify your
>point, rather than referring to the RM, it seemed to me that you were
>talking about what is or is not logically possible, rather than what
>happens to be the case. I seem to have misinterpreted you, so my
>apologies.
OK. I think the essence of the discussion is that in a language
(like Ada) that does not compel initialization, it is undecidable
whether a given variable has a well-defined (put there by the program)
value when it is used.
>
>If you're talking about Ada-as-it-is, then the compiler should issue a
>warning, but accept the code. It should do the same thing even for
>a code fragment such as
>
> X: Integer;
> begin
> put(X);
>
>unless it can prove that this code fragment will be executed.
Indeed. A compiler should give a warning, and in my experience, does,
if it can make a reasonably good guess. Some compilers (I think)
provide a compile-time flag that the programmer wants to treat warnings
as though they were fatal errors. I don;t see anything in gnatinfo to
suggest that GNAT does this, though.
>
>If you're talking about Ada-as-it-should-be, then the question is
>more debatable. I think it is a good idea for compilers to warn
>about such constructs, and a good idea for programmers to always
>restructure their code to avoid such warnings. If you accept that,
>it's only a short step from there to agreeing that these messages
>should be errors rather than warnings.
"Error" vs. "warning" is a bit arbitrary; I think it's really kind
of religious. We're talking Ada-as-it-should-be here. For example,
a friendly Ada-as-it-is compiler will give a warning if, say, it _knows_
that Constraint_Error will be raised. This cannot legally be an error,
and in fact, there are cases where the programmer _wants_ to force an
exception in an obvious way (say, to test his exception-handling code!).
So the programmer really should have the choice of handling here.
The treat-warnings-as-fatal flag would do this. Sure, we could take
a religious position that the _default_ should be a fatal error;
that would not bother me at all.
>
>If you transliterate that example from Ada to Mercury, and try
>compiling the resuling code, the Mercury compiler will report an error
>"mode mismatch in if-then-else", and will tell you that `X' is bound in
>one branch of the if-then-else, but not in the other.
So Mercury is producing an error where Ada would produce a warning.
As I said, I think this is just a matter of taste.
>
>>Does Java _compel_ initialization?
>
>My copy of the Java language specification is elsewhere at the moment,
>and I don't have a Java compiler at hand to test, so there is a quite
>large chance that I may be wrong about this, but I _think_ that
>Java does not require initialization at the point of declaration,
>but instead requires that a variable be initialized along all the
>execution paths leading to a possible use of a that variable;
>that would mean that if a variable wasn't used, there would be
>no requirement to initialize it.
And if it _was_ used? How does the JBC interpreter know whether it's
been initialized? Possibly in the interpreter, there's a "this space
is uninitialized" flag. As I recall, there have even been such bits
in certain hardware architectures. But the "undecidability" issue
was referring to the _general_ platform case for Ada-as-it-is.
Mike Feldman
next prev parent reply other threads:[~1996-07-23 0:00 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-07-18 0:00 Uninitialized "out" parameters Paul Whittington
1996-07-18 0:00 ` Adam Beneschan
1996-07-18 0:00 ` Robert Dewar
1996-07-19 0:00 ` Samuel Tardieu
1996-07-19 0:00 ` John Herro
1996-07-19 0:00 ` Tucker Taft
1996-07-23 0:00 ` Peter Hermann
1996-07-23 0:00 ` Robert A Duff
1996-07-19 0:00 ` Dale Stanbrough
1996-07-19 0:00 ` Adam Beneschan
1996-07-19 0:00 ` James A. Squire
1996-07-19 0:00 ` Adam Beneschan
1996-07-20 0:00 ` Michael Feldman
1996-07-21 0:00 ` Fergus Henderson
1996-07-21 0:00 ` Michael Feldman
1996-07-21 0:00 ` Robert Dewar
1996-07-22 0:00 ` Fergus Henderson
1996-07-23 0:00 ` Michael Feldman [this message]
1996-07-23 0:00 ` Robert Dewar
1996-07-25 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Robert A Duff
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-19 0:00 ` Pascal Obry
1996-07-19 0:00 ` Peter Hermann
1996-07-18 0:00 ` Robert Dewar
1996-07-19 0:00 ` Peter Amey
1996-07-20 0:00 ` Fergus Henderson
1996-07-20 0:00 ` Robert Dewar
1996-07-21 0:00 ` Fergus Henderson
1996-07-21 0:00 ` Robert Dewar
1996-07-23 0:00 ` Fergus Henderson
1996-07-23 0:00 ` Robert A Duff
1996-07-24 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Fergus Henderson
1996-07-23 0:00 ` Richard A. O'Keefe
1996-07-23 0:00 ` Robert A Duff
1996-07-24 0:00 ` Richard A. O'Keefe
1996-07-24 0:00 ` Theodore E. Dennison
1996-07-24 0:00 ` Robert A Duff
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-25 0:00 ` Robert A Duff
1996-07-25 0:00 ` Frank Manning
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-26 0:00 ` Frank Manning
1996-07-23 0:00 ` Robert Dewar
1996-07-24 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Robert A Duff
1996-07-24 0:00 ` Fergus Henderson
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-25 0:00 ` Robert A Duff
1996-07-19 0:00 ` Peter Amey
1996-07-19 0:00 ` Michel Gauthier
1996-07-21 0:00 ` Robert A Duff
1996-07-21 0:00 ` Robert A Duff
1996-07-22 0:00 ` Is 'out' different from 'in out' (Was: Uninitialized "out" parameters) Michel Gauthier
1996-07-22 0:00 ` Robert A Duff
1996-07-22 0:00 ` Robert Dewar
1996-07-22 0:00 ` Tucker Taft
1996-07-23 0:00 ` Michel Gauthier
1996-07-23 0:00 ` Robert Dewar
1996-07-24 0:00 ` Pascal Obry
1996-07-25 0:00 ` Tucker Taft
1996-07-23 0:00 ` Uninitialized "out" parameters John Herro
1996-07-23 0:00 ` Robert Dewar
1996-07-24 0:00 ` Peter Hermann
1996-07-23 0:00 ` Robert A Duff
1996-07-24 0:00 ` Uninitialized variables, Java example Arra Avakian
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-25 0:00 ` Robert A Duff
1996-07-25 0:00 ` Robert A Duff
1996-07-26 0:00 ` Uninitialized "out" parameters Stephen J Bevan
1996-07-26 0:00 ` Robert A Duff
1996-07-24 0:00 ` Uninitialized variables, Java example Felaco
-- strict thread matches above, loose matches on Subject: below --
1996-07-29 0:00 Uninitialized out parameters W. Wesley Groleau (Wes)
2016-04-05 12:02 ahlan
2016-04-05 13:17 ` rieachus
2016-04-05 14:07 ` ahlan
2016-04-06 9:45 ` Mark Lorenzen
2016-04-06 21:01 ` Jeffrey R. Carter
2016-04-07 7:10 ` ahlan
2016-04-05 16:19 ` G.B.
2016-04-06 8:19 ` ahlan
2016-04-06 10:17 ` G.B.
2016-04-06 11:44 ` Dennis Lee Bieber
2016-04-06 20:41 ` Niklas Holsti
2016-04-06 20:54 ` Randy Brukardt
2016-04-06 20:47 ` Randy Brukardt
2016-04-06 21:01 ` Randy Brukardt
2016-04-06 21:22 ` Dmitry A. Kazakov
2016-04-07 7:27 ` Randy Brukardt
2016-04-06 11:37 ` AdaMagica
2016-04-06 13:44 ` ahlan
2016-04-06 14:09 ` Mark Lorenzen
2016-04-06 14:10 ` G.B.
2016-04-06 20:53 ` Stefan.Lucks
2016-04-06 21:03 ` Randy Brukardt
2016-04-06 21:12 ` Niklas Holsti
2016-04-06 21:30 ` Randy Brukardt
2016-04-07 9:56 ` Stefan.Lucks
2016-04-07 16:08 ` AdaMagica
2016-04-07 23:02 ` Randy Brukardt
2016-04-08 7:32 ` Dmitry A. Kazakov
2016-04-07 7:52 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox