From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.38.157 with SMTP id l29mr9553072otb.123.1492558951956; Tue, 18 Apr 2017 16:42:31 -0700 (PDT) X-Received: by 10.157.8.17 with SMTP id 17mr302oty.20.1492558951918; Tue, 18 Apr 2017 16:42:31 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!e132no842511ite.0!news-out.google.com!g66ni2742itc.0!nntp.google.com!c26no21056itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 18 Apr 2017 16:42:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.130.162.123; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 50.130.162.123 References: <178b6fbc-229b-49fc-8ffb-a5797bfc335f@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <61e151c1-9fe6-4d32-8f13-d425bc41a616@googlegroups.com> Subject: Re: Is there a reason System.Storage_Pools isn't Pure? From: Shark8 Injection-Date: Tue, 18 Apr 2017 23:42:31 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:46594 Date: 2017-04-18T16:42:31-07:00 List-Id: On Tuesday, April 18, 2017 at 12:32:34 PM UTC-6, Randy Brukardt wrote: > Originally, it was not Pure because it was a child of System, which was not > Pure. So I can't find any discussion of the merits. > > However, Pure packages are automatically Remote_Types packages (that is, > values of the type can be transmitted between partitions). We'd never want > that to be the case with a storage pool, so there doesn't seem to be any > point in it being Pure. Are we sure we'd never want that? I imagine that would be an interesting way to do VMs -- essentially transmitting the [contained] memory directly between partitions, right? -- so we could essentially solve the problems plaguing JavaScript/backend development (in theory) with this, right? > Additionally, the Pure package rules assume that no storage pools can be > specified for access types (because there aren't rules banning that at > library-level, and there need to be such rules to prevent hidden state). > That could be changed, I suppose, but given that a Pure storage pool could > only be used for a local access type in a Pure package(something that mainly > exists in ACATS tests), it would be close to useless (or get used for > back-door state). Note that state has to be strictly prohibited as Pure > packages are replicated when used in a distributed system (thus each > partition would have different state, which wouldn't make sense). 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? > IMHO, Pure packages are too restricted to be useful (and not restricted > enough to be useful when synchronization is involved); it makes sense for > individual subprograms but not for an entire package. So I recommend only > trying to make packages Preelaborated. (That's especially true in Ada 2012, > where limited I/O is possible.) [Distribution might change this thinking; > I'm only considering stand-alone programs that don't use Annex E.] That's probably truer than I'd like -- but I guess the question was borne out of playing around w/ pure units and seeing how far I could push the style-guide's instruction "Use pragma Pure where allowed." ( https://en.wikibooks.org/wiki/Ada_Style_Guide/Print_version#Pragma_Pure )