Re: In-Out Parameters for functions

From: Hyman Rosen (hyrosen_at_mail.com)
Date: 01/29/04

  • Next message: Georg Bauhaus: "Re: In-Out Parameters for functions"
    Date: Thu, 29 Jan 2004 14:46:22 -0500
    
    

    David Starner wrote:
    > Why should buggy code work?

    I don't think you understand. As Ada stands now, it is perfectly
    legal to write code which has unspecified results due to order of
    execution. In general, the compiler cannot know whether particular
    code has such order dependencies or not, and so cannot reliably
    warn of such uses. Therefore, it's possible for such code to slip
    undetected into production, and to survive testing because the
    order chosen by the compiler is the "correct" one. Then some change
    occurs in the environment, such as changing optimization level,
    or changing platform, and now the compiler makes a different choice
    and the code stops working.

    You cannot make the argument that raesonable care would prevent this.
    That is the same argument that C programmers make for the compiler not
    checking array bounds or pointer access, and Ada proponents roundly
    reject such arguments.

    Therefore, the best thing to do is to eliminate the lack of specificity,
    so that a line of code will be executed in the same order always. Once
    this is in place, then depending on the order of evaluation within an
    expression will be no more problematic than depending on the order of
    execution of a pair of statements, and will not be "buggy". As for its
    utility, I submit that code like this:
         Point p := (x => ReadCoord, y => ReadCoord, z => ReadCoord);
    is perfectly sensible once you forget that order of evaluation was ever
    an issue and accept left-to-right as the natural way of things. Why is
    this statement any worse than
         cx, cy, cz : Coord := ReadCoord;
         Point p := (x => cx, y => cy, z=> cz);


  • Next message: Georg Bauhaus: "Re: In-Out Parameters for functions"

    Relevant Pages

    • Re: In-Out Parameters for functions
      ... As Ada stands now, it is perfectly ... and now the compiler makes a different choice ... Writting programs depending on evaluation order in a way that the ...
      (comp.lang.ada)
    • Re: Current status of Ada?
      ... learning and using this great language. ... The reason why compilers maker can't make their compiler totally free ... I agree with you that most of the links you can find on Ada websites ... AdaCore has contributed a free gnat compiler to ...
      (comp.lang.ada)
    • Re: Ravenscar-compliant bounded buffer
      ... the mid 1980's most compiler are FRONT_END compilers aka ... any system build around GNAT will contain the C code that GNAT ... The XGC Ada which is based on GNAT and uses C for its Real Time ... with VAXes for data processing applications. ...
      (comp.lang.ada)
    • Re: 7E7 Flight Controls Electronics
      ... Given that people had choices and Ada ... the 800 or so programming languages in use by the DoD, ... DoD1 was expected to provide a 'language of last resort', ... need modifications to a compiler to support particular requirements, ...
      (comp.lang.ada)
    • Re: Distributed Computing in Ada
      ... no shared memory. ... Ada tasks /can/ share memory, ... The problem is that the compiler can't know which variables are shared. ... The unit of distribution ...
      (comp.lang.ada)