comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: two questions on allocators
Date: Thu, 1 Mar 2018 09:30:55 +0100
Date: 2018-03-01T09:30:55+01:00	[thread overview]
Message-ID: <p78do1$1hql$1@gioia.aioe.org> (raw)
In-Reply-To: p77egm$k05$1@franka.jacob-sparre.dk

On 01/03/2018 00:37, Randy Brukardt wrote:
> "Robert A Duff" <bobduff@TheWorld.com> wrote in message
> news:wcczi3t6qqh.fsf@TheWorld.com...
>> Mehdi Saada <00120260a@gmail.com> writes:
>>
>>> I saw that since I (tried to) read the AARM, but didn't really got
>>> it. Now it's ok. If the problem of these null forbidding hypothetic
>>> subtypes is that can't have the default null value, why not just require
>>> the user to give one ?
>>
>> Don't use "not null"; it's broken as you see.  Instead, do:
>>
>>     subtype S is T with Predicate => S /= null;
> 
> ??? You'd get the same problem with the allocators (that they always raise
> an exception) with this formulation.
> 
> If you did want a subtype to use for an initialized allocator (which the OP
> specifically wasn't using), then
> 
>      subtype S is not null T;
> 
> works just fine. And this at least is guaranteed to be checked everywhere
> necessary, that's not true for a Dynamic_Predicate (as you know).
> 
> Probably in most cases, they are equivalent, but when they are not
> equivalent, it is just because you have pushed static checks to runtime,
> which hardly seems to be an advantage.

True. Dynamic checks is evil unless a contract. The contract "raise 
Constraint_Error if null" is already there, which makes all exercise 
pointless.

---
As I keep on repeating: constructors, they must be here. There is no way 
to work that fundamental block around. Otherwise we will always be 
running into the same problem that any assignment has a left side, which 
must be come from somewhere and be conform with all constraints 
including ones of the right side.

There is nothing wrong with "not null access" except for lack of 
constructors in Ada.

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

  reply	other threads:[~2018-03-01  8:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 20:42 two questions on allocators Mehdi Saada
2018-02-23 22:30 ` Shark8
2018-02-23 23:30   ` Mehdi Saada
2018-02-25  2:17     ` Randy Brukardt
2018-02-24 10:20   ` AdaMagica
2018-02-24 10:18 ` AdaMagica
2018-02-25 12:12 ` Mehdi Saada
2018-02-26 23:02   ` Randy Brukardt
2018-02-28 16:09   ` Robert A Duff
2018-02-28 23:37     ` Randy Brukardt
2018-03-01  8:30       ` Dmitry A. Kazakov [this message]
2018-03-01 23:17       ` Robert A Duff
2018-03-01 23:47         ` Shark8
2018-03-02  9:20         ` Simon Wright
2018-03-02 22:37           ` Randy Brukardt
2018-03-02 22:31         ` Randy Brukardt
replies disabled

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