comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: two questions on allocators
Date: Wed, 28 Feb 2018 17:37:57 -0600
Date: 2018-02-28T17:37:57-06:00	[thread overview]
Message-ID: <p77egm$k05$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: wcczi3t6qqh.fsf@TheWorld.com

"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.

                                              Randy.


  reply	other threads:[~2018-02-28 23:37 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 [this message]
2018-03-01  8:30       ` Dmitry A. Kazakov
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