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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,585fd78267abd80c X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: On pragma Precondition etc. Date: Fri, 25 Jul 2008 10:39:49 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4889886d$0$18827$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1216996790 4499 192.74.137.71 (25 Jul 2008 14:39:50 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 25 Jul 2008 14:39:50 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:e3Y+Wlz4KvV6HrwlKSpFAppQP/A= Xref: g2news1.google.com comp.lang.ada:1330 Date: 2008-07-25T10:39:49-04:00 List-Id: 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