comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: [Newbie] doubly constrained array, dumb question
Date: Tue, 27 Feb 2018 15:19:20 +0100
Date: 2018-02-27T15:19:20+01:00	[thread overview]
Message-ID: <p73pd7$1u4$1@gioia.aioe.org> (raw)
In-Reply-To: 576b1f3a-a0f4-42c9-b7b5-082600ad74c5@googlegroups.com

On 27/02/2018 12:43, Mehdi Saada wrote:
>> For example, the "class" Integer of which
>> Positive is a "member" still has negative values, it is just so that you
>> cannot tag them Positive. E.g.
>>      A : Positive := 1;
>>      B : Positive := 100;
>>      C : Positive := (A - B) + B; -- This is OK, though A - B = -99
> Interesting, I never tried that ! Very useful indeed.
> But those types don't have classes, nor polymorphism.

They have "classes", but no *dynamic* polymorphism.

>> Not necessarily. You simply override disallowed operations with bodies
>> raising Constraint_Error. The same technique is used for multiple dispatch:
> Yes, I thought so, but it's definitely not my conception of safe and "predictable"... It's safer that "whatever is defined for the parent, won't raise exception for the descendants" holds true at any time.

It is safe because that is the defined behavior. Disallowed operation is 
defined as exception, not as never-called-thing.

Compare that with zero divide, there is nothing unsafe in that, it is 
defined to raise Constraint_Error. Unsafe is when a contract is 
violated. If a client promises not to propagate exceptions and then 
divides to zero without catching Constraint_Error, that is an unsafe 
*client*, division is still safe.

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

  reply	other threads:[~2018-02-27 14:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26 16:26 [Newbie] doubly constrained array, dumb question Mehdi Saada
2018-02-26 17:02 ` J-P. Rosen
2018-02-26 21:40   ` Dmitry A. Kazakov
2018-02-26 23:26   ` Randy Brukardt
2018-02-27  9:01     ` Simon Wright
2018-02-27 22:11       ` Randy Brukardt
2018-02-26 20:52 ` Niklas Holsti
2018-02-27  1:29 ` Mehdi Saada
2018-02-27  9:18   ` Dmitry A. Kazakov
2018-02-27 11:43     ` Mehdi Saada
2018-02-27 14:19       ` Dmitry A. Kazakov [this message]
2018-02-27 17:08     ` G. B.
2018-02-27 17:37       ` Dmitry A. Kazakov
2018-02-27 14:34   ` Jere
2018-02-27 15:13     ` Dmitry A. Kazakov
2018-02-27  7:38 ` Jacob Sparre Andersen
replies disabled

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