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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: What about a Static_Assertion? Date: Tue, 23 Jul 2013 20:07:54 +0200 Organization: Ada @ Home Message-ID: NNTP-Posting-Host: isXxzoEpMdi8+8WFlqpEZw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 2610 Xref: number.nntp.dca.giganews.com comp.lang.ada:182660 Date: 2013-07-23T20:07:54+02:00 List-Id: Hi Ada novelists, Don't you believe it would be great to have static assertion just like w= e = have static predicates? Would play the role of a package Static_Predicate when at package level = = and of an implementation Static_Predicate when at a sub=E2=80=91program = level. Assertions are great, but I can't avoid the feeling more distinction = between the very different kinds (very different in the implications) of= = assertions would be profitable. To be more precise, I see at least three kinds: * The assertion uses a static expression * The assertion uses a constant expression (may not be static!) * The assertion uses a variable expression All three are not the same, and it would be nice to be allowed to = explicitly state the kind of assertion we are making. The compiler could= = check what is said to be a constant assertion does not unfortunately = depends on a variable entity, and this would help to trust and better = understand the consequence of what you read. I believe this would not be too much a nightmare to be added to any Ada = = 202X, this would just requires a check on the kind of the expression use= d = for the assertion, and failure of a static assertion, could be said to = make the compilation to necessary fails. So what about to have `pragma Static_Assertion (=E2=80=A6)`, `pragma = Constant_Assertion (=E2=80=A6)` and `pragma Assert (=E2=80=A6)` (the cla= ssic one, for = variable assertions)? -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity