comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Subtypes and type invariants in Ada2012
Date: Mon, 21 Aug 2017 18:18:27 +0200
Date: 2017-08-21T18:18:27+02:00	[thread overview]
Message-ID: <onf14l$9uv$1@gioia.aioe.org> (raw)
In-Reply-To: oneuqr$5l9$1@gioia.aioe.org

On 2017-08-21 17:38, Victor Porton wrote:

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

Type invariant is not a restriction of public interface/properties, it 
is an implementation detail. So it should never produce a [sub]type.

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

Arbitrary condition breaks type operations. E.g. condition Is_Prime (X) 
breaks more or less everything (assuming covariance). All restrictions 
do. A few don't break much, e.g. range constraints.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2017-08-21 16:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
replies disabled

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