comp.lang.ada
 help / color / mirror / Atom feed
* What about a Static_Assertion?
@ 2013-07-23 18:07 Yannick Duchêne (Hibou57)
  2013-07-23 18:43 ` Dmitry A. Kazakov
  2013-07-23 21:46 ` Georg Bauhaus
  0 siblings, 2 replies; 5+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2013-07-23 18:07 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-23 21:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 18:07 What about a Static_Assertion? Yannick Duchêne (Hibou57)
2013-07-23 18:43 ` 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

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