comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: On pragma Precondition etc.
Date: Fri, 25 Jul 2008 10:39:49 -0400
Date: 2008-07-25T10:39:49-04:00	[thread overview]
Message-ID: <wcchcaegh8q.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: Pine.LNX.4.64.0807251224010.10913@medsec1.medien.uni-weimar.de

stefan-lucks@see-the.signature writes:

> On Fri, 25 Jul 2008, Georg Bauhaus wrote:
>
>> We would have something like
>> 
>>    function More(X, Y: Integer);
>>    -- ...
>>    pragma Precondition(More, X > 2 * Y);
>> 
>> 
>>    function Less(X, Y: Integer);
>>    -- ...
>>    pragma Precondition(Less, X < 2 * Y);
>> 
>> And now there is no doubt about the subprogram to which a
>> Pre-/Postcondition belongs.  (A rule that a spec Pre-/Postcondition
>> pragma must come right after its subprogram will establish
>> consistency.)
>
> This seems to break with overloading of subprogram names. I seem to recall 
> that 
>   "pragma Inline(Foo)" 
> is asking to inlie *all* functions / procedures with the name "Foo" This 
> may be OK for inlining, but you definitively don't want to use the same 
> preconditions which happen to have the same way.

I don't think it's OK for pragma Inline (or Convention, or any of the
others).  The rules are confusing, especially the way they work with
renaming.

I think a better design would be to require every procedure to have a
unique name (plus, optionally, an overloaded name).

Syntax for pre/postconditions is a good idea, but for now it's a
GNAT-specific extension, so pragmas are better.

> An alternative would be to repeat the entire function declaration in the 
> pragma:
>
>   function More(X, Y: Integer) return Integer; 
>   pragma Precondition(function More(X,Y: Integer) return Integer, 
>                       X > 2 * Y); --1--

That's syntactically illegal.  The RM allows implementations to invent
pragmas, but does not allow them to modify the general syntax of
pragmas.

> would throw a bit too much of redundant information at the reader. 

Yeah, that too.

- Bob



  parent reply	other threads:[~2008-07-25 14:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-25  8:01 On pragma Precondition etc Georg Bauhaus
2008-07-25 10:50 ` stefan-lucks
2008-07-25 11:05   ` mockturtle
2008-07-25 11:44     ` Alex R. Mosteo
2008-07-25 11:56       ` Georg Bauhaus
2008-07-28  8:02         ` Alex R. Mosteo
2008-07-29 11:18       ` Martin Krischik
2008-07-29 12:08         ` Dmitry A. Kazakov
2008-07-29 14:19           ` Georg Bauhaus
2008-07-29 14:49             ` Georg Bauhaus
2008-07-29 15:00             ` Dmitry A. Kazakov
2008-07-29 15:14               ` Georg Bauhaus
2008-07-29 15:55               ` Georg Bauhaus
2008-07-29 17:49                 ` Dmitry A. Kazakov
2008-07-30  9:06                   ` Georg Bauhaus
2008-07-30 13:47                     ` Dmitry A. Kazakov
2008-07-30 17:45                       ` Georg Bauhaus
2008-07-31  8:12                         ` Dmitry A. Kazakov
2008-07-31 23:06                           ` Georg Bauhaus
2008-08-01  8:40                             ` Dmitry A. Kazakov
2008-07-30  9:22                   ` Georg Bauhaus
2008-07-30 13:56                     ` Dmitry A. Kazakov
2008-07-25 14:39   ` Robert A Duff [this message]
2008-07-25 16:50 ` Pascal Obry
replies disabled

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