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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.albasani.net!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada package registry? Date: Thu, 11 Feb 2016 16:00:58 -0600 Organization: JSA Research & Innovation Message-ID: References: <02241ec4-0f95-4f63-9abc-092f167eb59e@googlegroups.com> <56af17b7$0$301$14726298@news.sunsite.dk> <56b06eb8$0$301$14726298@news.sunsite.dk> <1454483747.2785.135.camel@obry.net> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1455228059 28210 24.196.82.226 (11 Feb 2016 22:00:59 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 11 Feb 2016 22:00:59 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:29499 Date: 2016-02-11T16:00:58-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:n9hgje$vai$1@gioia.aioe.org... > On 11/02/2016 02:37, Randy Brukardt wrote: >> "Dmitry A. Kazakov" wrote in message >> news:n9c9a8$mt9$1@gioia.aioe.org... >>> On 09/02/2016 00:02, Randy Brukardt wrote: >>>> "Dmitry A. Kazakov" wrote in message >>>> news:n94cbv$19ed$1@gioia.aioe.org... >>> >>>>> For persistence layer you need dereference primitive operations. One >>>>> for >>>>> read access in order to cache data and one write access to mark the >>>>> cache >>>>> dirty. >>>> >>>> The first is the function call (to Reference, if you're looking at the >>>> Ada >>>> containers), and the second is the Finalize call that happens when the >>>> object returned from Reference goes away. That was the whole point of >>>> the >>>> design. (Of course, you could have written that in Ada 95, but without >>>> the >>>> syntactic sugar that makes it easier to read and write.) >>> >>> It is not same. A reference points to a proxy object, a cached copy of >>> the >>> external object in the persistent storage. When the proxy object is >>> updated via any reference, it must be marked dirty. So that when the >>> object at some point gets finalized or the transaction is committed it >>> would be written back to the storage. >> >> But actually they are the same, because the reference can only exist for >> a >> very short time. (You can't assign a reference because the accessibility >> is >> too shallow.) Thus, the proxy object can be marked dirty (if you created >> a >> writable reference, which is only created when you actually use the >> reference in a writable context) and written back to the persistent >> storage. > > Writing objects is very expensive. So objects must be reference counted > anyway. I don't see how the schema can handle all this, as well as > inducing the reference type (read-only vs. read-write) from the context. The language rules determine the reference type from context, so that's done automatically for you. (And, yes, there are ACATS tests for it, so a conforming Ada compiler will do it correctly -- now. [The tests failed on compilers when they came out, but those problems were swiftly fixed.]) See the difference between Reference and Constant_Reference in the Ada.Containers library. You don't necessarily have to reference count objects, especially if you use a read-write lock (as discussed below); in that case, there can never be more than one writable reference active at a time anyway. But you surely can do that. >> You do have to make sure that only one task is potentially writing a >> proxy >> object at a time, but that seems like a good thing. > > Not good. Object updating through a reference and handling reference > counts must be atomic. References must act as read-write locks. That's what I meant: the implementation of Reference can include an appropriate read-write lock. I wouldn't leave it to the programmer to get right. Everything you've asked about is present in the Ada 2012 features (or before), so I think it's possible to write such a library and have it work reasonably transparently. Not having tried it myself, I don't want to make a 100% certainty claim, but surely we intended that it would work. Randy.