comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Is there a reason System.Storage_Pools isn't Pure?
Date: Wed, 19 Apr 2017 15:36:26 -0500
Date: 2017-04-19T15:36:26-05:00	[thread overview]
Message-ID: <od8hob$n82$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 61e151c1-9fe6-4d32-8f13-d425bc41a616@googlegroups.com

"Shark8" <onewingedshark@gmail.com> wrote in message 
news:61e151c1-9fe6-4d32-8f13-d425bc41a616@googlegroups.com...
...
> What about a usable-for-anything holder? (In particular, I think that 
> Ada.Containers.Indefinite_Holders ought to be less restrictive than they 
> are.) We could have a Pure Indefinite_Holder with:
>
>    Generic
>      Type Element_Type(<>) is limited private;
>      -- Pure storage-pool as a parameter? a dependency?
>    Package Example with Pure, Spark_Mode => On is
>      Type Holder is private;
>      Function Has_Element( Container : Holder ) return Boolean;
>      Function Element( Container : Holder ) return Element_Type
>        with Pre => Has_Element( Container );
>      Procedure Clear( Container : in out Holder )
>        with Post => not Has_Element( Container );
>    Private
>      Pragma SPARK_Mode( Off );
>
>      Type is access Element_Type
>        with Storage_Size => 0; -- Pure pool storage to allow non-zero?
>
>      Function Has_Element( Container : Holder ) return Boolean is
>        (Container /= Null);
>      Function Has_Element( Container : Holder ) return Boolean is
>        (Container.All);
>    End Example;
>
> Or am I misunderstanding?

Your spec here doesn't have any way to put an element into the holder. And 
that's where the trouble comes (especially for limited types!). Perhaps you 
can figure it out (I haven't been able to). As it stands, your holder 
objects would have to have Has_Element = False. Not very useful. ;-)

                              Randy.
 


  parent reply	other threads:[~2017-04-19 20:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18  6:31 Is there a reason System.Storage_Pools isn't Pure? Shark8
2017-04-18 18:32 ` Randy Brukardt
2017-04-18 23:42   ` Shark8
2017-04-19  7:37     ` Dmitry A. Kazakov
2017-04-19 18:50       ` Shark8
2017-04-19 19:48         ` Dmitry A. Kazakov
2017-04-19 20:42       ` Randy Brukardt
2017-04-19 20:36     ` Randy Brukardt [this message]
2017-04-20  0:12       ` Shark8
2017-04-22  5:02         ` Randy Brukardt
2017-04-22 17:18           ` Shark8
replies disabled

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