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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9e499c74312ed3f0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-19 01:50:01 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!194.213.69.151!news.algonet.se!newsfeed1.telenordia.se!algonet!newsfeed1.funet.fi!newsfeed2.funet.fi!newsfeeds.funet.fi!news.helsinki.fi!not-for-mail From: aaro@iki.fi (Aaro Koskinen) Newsgroups: comp.lang.ada Subject: Re: Static assertions Date: 19 May 2001 11:36:00 +0300 Organization: University of Helsinki Message-ID: References: <9e0pfb$ao9$1@s1.read.news.oleane.net> NNTP-Posting-Host: sirppi.helsinki.fi X-Trace: oravannahka.helsinki.fi 990261362 475 128.214.205.27 (19 May 2001 08:36:02 GMT) X-Complaints-To: usenet@news.helsinki.fi NNTP-Posting-Date: 19 May 2001 08:36:02 GMT X-Newsreader: Gnus v5.3/Emacs 19.34 Xref: archiver1.google.com comp.lang.ada:7647 Date: 2001-05-19T08:36:02+00:00 List-Id: "Jean-Pierre Rosen" writes: > Still discovering how powerful Ada is... > > Imagine your program relies on Integer having a certain size, or being sure > that the size of Integer is four times the size of character, or things like > that, and you want to make sure that the program does not even compile if > the assertions do not hold (because you hate fighting with a debugger). This > is possible, since a static expression that raises constraint_error will not > compile. I have been using a similar method in C. I have an assert macro, which declares a const int with the value "1 / ". If the assertion does not hold, it evaluates to 0, and the code will not compile. -- Aaro Koskinen, aaro@iki.fi, http://www.iki.fi/aaro