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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,78447032bdbeb343 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!204.127.161.8.MISMATCH!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Proposal: pragma Assumption Reply-To: anon@anon.org (anon) References: <30917be5-1446-417c-8a4e-18b2f9a1f420@b1g2000hsg.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Tue, 27 May 2008 03:28:43 GMT NNTP-Posting-Host: 12.65.96.206 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1211858923 12.65.96.206 (Tue, 27 May 2008 03:28:43 GMT) NNTP-Posting-Date: Tue, 27 May 2008 03:28:43 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:381 Date: 2008-05-27T03:28:43+00:00 List-Id: First, conditional compiling does not exist in the Ada Language and should never exist because of the purpose of Ada to be portable. Just look at any C or C++ compilers except for a few simple "conditional statement" every version has it own "conditional statements". Which makes most of these older language compilers less desirable to use. That is one reason we like and use Ada. Second, the "Ada Language Maintainers" would have to agree to create a simple "conditional compilation". And would it use "pragma" statement or another new statement. At the earliest that would be included in 2015 or better yet 2025. Third, macros are apart of an advance "conditional compilation" which would be added in 2025 or 2035. Which means is statement is too far into the future for most people. In <30917be5-1446-417c-8a4e-18b2f9a1f420@b1g2000hsg.googlegroups.com>, =?ISO-8859-1?Q?Santiago_Urue=F1a?= writes: >Hi everybody, > >I'm thinking in sending the following proposal to the ARG, but I'd >like to present it here first to have more opinions about it >usefulness, and probably to refine it a bit with your comments... > >It is based on a 2004 paper of Tony Hoare (from the book 'From Object- >orientation To Formal Methods') where he describes different types of >assertions used by (C/C++) developers in production code, including >this one: > > SYMPLIFYING_ASSUMPTION (strlen(input) > MAX_PATH, "not yet checking >for overflow"); > >'SYMPLIFYING_ASSUMPTION' is a macro very similar to the C 'assert', >also checking at run-time a boolean condition and aborting the program >if it evaluates to false. But if an 'assert' is valid during the whole >life of the application, the 'SYMPLIFYING_ASSUMPTION' is used by the >programmer just *during the coding phase* to document those cases that >aren't coded yet (probably edge cases). The difference is when >compiling the program _not_ in debug mode (NDEBUG defined): the >'assert' macros are eliminated by the preprocessor whereas it is a >compilation error if any 'SYMPLIFYING_ASSUMPTION' remains in the >sources. > >That is, a SYMPLIFYING_ASSUMPTION is like those 'TODO:' or 'FIXME:' >annotations used to remind the programmer what should be modified in >the code, but it is recognized by the compiler instead of being just a >comment, and therefore cannot be ignored by accident. > > >So the proposal whould be adding to the next Ada revision two new >pragmas: > > pragma Assumption ([Check =3D>] boolean_expression[, [Message =3D>] >string_expression]); > pragma Assumption_Policy (policy_identifier); -- Error, Check > >Which behave exactly like Assert and Assertion_Policy (also raising >Assertion_Error, but with a different message), except that by default >it is a compilation error to find any pragma Assumption in the sources >unless when explicitly allowed using a compilation flag or the 'Check' >policy. > >Probably better names can be chosen for those pragmas, so feel free to >propose more adequate identifiers. Also, maybe in this case the >Message string should be required, anyway it is a documentation pragma >(in pragma Assert the second parameter is optional). > >IMHO this pragma is not a complete replacement for the TODO or FIXME >comments, and in many cases it is better to code the whole >functionality at once than just the more common cases. However, >sometimes it will be a good approach to code just some cases >documenting the assumptions, run the testsuite (raising an exception >if any of those missing cases are triggered), and to code the rest in >the future. But now, even if you forget to add that code, the compiler >will remind you about those missing cases when trying to compile the >final executable (following the "programmers make faults" Ada >philosophy). > >Do you think it is an useful addition to Ada 2015? Would you use this >feature? Do you know of any means to achieve the same effect in Ada >2005? Thanks > >Cheers, > >-- >Santiago Urue=F1a-Pascual >Technical University of Madrid (UPM)