comp.lang.ada
 help / color / mirror / Atom feed
* Type_Invariant and Finalize
@ 2014-07-17 18:15 Natasha Kerensikova
  2014-07-17 20:49 ` Simon Wright
  2014-07-17 21:30 ` Type_Invariant and instance creation (was: Type_Invariant and Finalize) Simon Wright
  0 siblings, 2 replies; 7+ messages in thread
From: Natasha Kerensikova @ 2014-07-17 18:15 UTC (permalink / raw)


Hello,

I have been trying out the new contrat-oriented aspects on Ada 2012, and
wondered how Type_Invariant interacts with user-defined finalization.

I have several types for which a Type_Invariant makes sense (and is
often already mostly implemented the old-fashionned way, with pragma
Assert at the end of subprograms), except after the first call to
Finalize.

The latest example is a sorted array of non-null
paccess-to-indefinite-type values, where the "sortedness" is a natural
type inveriant, but in Finalize I release the memory using an instance
of Unchecked_Deallocation.

I'm already a bit uneasy with not having "not null except after
Finalize" access types, but in the example above after the first call to
Finalize I get an array of either null or invalid access values, and the
natural type invariant can't be computed.

Searching through the ARM, I can't see any special treatment of the
Finalize procedure with regard to Type_Invariant aspect, so presumably
the type inveriant is also checked at the end of Finalize.

Have I missed something that allows Finalize to make an object not fit
the type invariant?

Or should I prepare for it, e.g. with an explicit boolean record
component that is False for the most of the lifetime of the object,
until the first call to Finalize?


Thanks in advance for your insights,
Natasha

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

end of thread, other threads:[~2014-07-22  1:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17 18:15 Type_Invariant and Finalize Natasha Kerensikova
2014-07-17 20:49 ` Simon Wright
2014-07-18  6:56   ` Natasha Kerensikova
2014-07-18 21:48     ` Robert A Duff
2014-07-17 21:30 ` Type_Invariant and instance creation (was: Type_Invariant and Finalize) Simon Wright
2014-07-21 23:29   ` Randy Brukardt
2014-07-22  1:13     ` Type_Invariant and instance creation Shark8

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