comp.lang.ada
 help / color / mirror / Atom feed
* Subtypes and type invariants in Ada2012
@ 2017-08-21 15:38 Victor Porton
  2017-08-21 16:10 ` J-P. Rosen
  2017-08-21 16:18 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 7+ messages in thread
From: Victor Porton @ 2017-08-21 15:38 UTC (permalink / raw)


I thought that type invariants are designed for subtypes. I mistook!

--
package X is

  type T is tagged private;

  function F(P: T) return Integer;

  subtype S is T with Type_Invariant => F(T) > 10;

private

  type T is tagged
    record
      X: Integer;
    end record;

end;
--

This does not verify:

$ gnatgcc -c -gnat2012 x.ads
x.ads:7:23: aspect "Type_Invariant" only allowed for private type or 
corresponding full view

So, my question: Is it possible to restrict a subtype with something like a 
type invariant?

I want a subtype restricted by an arbitrary condition. Is it possible?

-- 
Victor Porton - http://portonvictor.org

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

end of thread, other threads:[~2017-08-21 19:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 15:38 Subtypes and type invariants in Ada2012 Victor Porton
2017-08-21 16:10 ` J-P. Rosen
2017-08-21 16:18 ` Dmitry A. Kazakov
2017-08-21 16:29   ` Victor Porton
2017-08-21 16:52     ` Dmitry A. Kazakov
2017-08-21 17:41       ` Victor Porton
2017-08-21 19:55         ` Dmitry A. Kazakov

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