comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: What about a Static_Assertion?
Date: Tue, 23 Jul 2013 20:07:54 +0200
Date: 2013-07-23T20:07:54+02:00	[thread overview]
Message-ID: <op.w0osngz1ule2fv@cardamome> (raw)

Hi Ada novelists,


Don't you believe it would be great to have static assertion just like we  
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‑program 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 used  
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 (…)`, `pragma  
Constant_Assertion (…)` and `pragma Assert (…)` (the classic one, for  
variable assertions)?

-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University


             reply	other threads:[~2013-07-23 18:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 18:07 Yannick Duchêne (Hibou57) [this message]
2013-07-23 18:43 ` What about a Static_Assertion? Dmitry A. Kazakov
2013-07-23 18:57   ` Yannick Duchêne (Hibou57)
2013-07-23 20:13     ` Dmitry A. Kazakov
2013-07-23 21:46 ` Georg Bauhaus
replies disabled

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