comp.lang.ada
 help / color / mirror / Atom feed
From: dale@cs.rmit.edu.au (Dale Stanbrough)
Subject: Re: Assertions
Date: 1999/05/22
Date: 1999-05-21T22:29:20+00:00	[thread overview]
Message-ID: <dale-2205990829190001@r1021c-20.ppp.cs.rmit.edu.au> (raw)
In-Reply-To: 3742eba5@eeyore.callnetuk.com

Nick Roberts wrote:

" Could you give, please, one or two further examples, in a little more
  detail?  I (if no-one else!) would appreciate this."

in response to my statement...

  |I want some assertions to be genuinely tested, while others to be used
  |as an adjunct to the type system (and thus the compiler can use it for
  |optimisation purposes).


For an assertion that I would like tested...


   procedure Insert (Root : in out Tree; Item : Element) is
   --  insert into a binary search tree
   begin
      -- insertion code.
      ...

      pragma Assert (Balanced (Root));
          -- test this, die if it fails

   end Insert;


This assertion would cause an exception if the assertion failed 
(i.e. the semantics that Tucker Taft recently described). The
compiler would not take advantage of this assertion to make any
optimisations.


For an assertion that could be used by the compiler to optimise
the code


   pragma Enforce (X in 1..9 or X in 20..29);

   case X is
      when  1..10 => Something;
      when 20..29 => Something_Else;
      when others => Put_Line ("Whoops!");
   end case;


In this example, the compiler could remove the others clause.
The "Enforce" (I don't think this is a good name, but I can't
think of anything better) is used to extend the type system.

One problem with the name "Assert" is that people have 
different views about what it actually means. Robert Dewar
considers that "Assert" _should_ be able to be used for
optimisation purposes.


Dale




  reply	other threads:[~1999-05-22  0:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-10  0:00 Assertions J & A Richardson
1999-05-10  0:00 ` Assertions Marin David Condic
1999-05-11  0:00   ` Assertions Robert Dewar
1999-05-11  0:00     ` Assertions Nick Roberts
1999-05-11  0:00       ` Assertions Robert Dewar
1999-05-12  0:00         ` Assertions Dale Stanbrough
1999-05-12  0:00           ` Assertions Robert Dewar
1999-05-12  0:00     ` Assertions Tucker Taft
1999-05-12  0:00       ` Assertions Larry Kilgallen
1999-05-12  0:00         ` Assertions Tucker Taft
1999-05-13  0:00         ` Assertions Nick Roberts
1999-05-17  0:00           ` Assertions Dale Stanbrough
1999-05-19  0:00             ` Assertions Nick Roberts
1999-05-22  0:00               ` Dale Stanbrough [this message]
1999-05-22  0:00                 ` Assertions Ray Blaak
1999-05-22  0:00                   ` Assertions Robert Dewar
1999-05-23  0:00                     ` Assertions Nick Roberts
1999-05-24  0:00                       ` Assertions Ray Blaak
1999-05-24  0:00                       ` Assertions Dale Stanbrough
1999-05-22  0:00                 ` Assertions Robert Dewar
1999-05-23  0:00                 ` Assertions Nick Roberts
1999-05-12  0:00       ` Assertions Marin David Condic
1999-05-18  0:00       ` Assertions Richard D Riehle
1999-05-19  0:00         ` Assertions Nick Roberts
1999-05-19  0:00           ` Assertions Richard D Riehle
1999-05-20  0:00             ` Assertions stimuli
1999-05-21  0:00               ` Assertions Richard D Riehle
1999-05-21  0:00                 ` Assertions Robert Dewar
1999-05-20  0:00             ` Assertions Ehud Lamm
1999-05-21  0:00               ` Assertions Robert Dewar
1999-05-21  0:00                 ` Assertions Ehud Lamm
1999-05-21  0:00                   ` Assertions Tucker Taft
1999-05-20  0:00           ` Assertions stimuli
1999-05-12  0:00 ` Assertions Peter Amey
1999-05-12  0:00   ` Assertions Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox