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 X-Received: by 2002:a5e:8346:: with SMTP id y6-v6mr4240198iom.7.1539973371544; Fri, 19 Oct 2018 11:22:51 -0700 (PDT) X-Received: by 2002:a9d:43:: with SMTP id 61mr397178ota.3.1539973371362; Fri, 19 Oct 2018 11:22:51 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.216.MISMATCH!x98-v6no87284ita.0!news-out.google.com!l70-v6ni106itb.0!nntp.google.com!z5-v6no87520ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 19 Oct 2018 11:22:51 -0700 (PDT) In-Reply-To: <0a680981-7b14-4b72-b51a-b06ab7822d54@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=75.99.9.146; posting-account=s89PEgoAAABHs2ETFyOrCeTQVQJAfzKq NNTP-Posting-Host: 75.99.9.146 References: <0a680981-7b14-4b72-b51a-b06ab7822d54@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: A function that cannot be called? From: marciant@earthlink.net Injection-Date: Fri, 19 Oct 2018 18:22:51 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:54660 Date: 2018-10-19T11:22:51-07:00 List-Id: On Friday, October 19, 2018 at 2:19:07 PM UTC-4, marc...@earthlink.net wrote: > On Thursday, October 18, 2018 at 8:14:32 AM UTC-4, G.B. wrote: > > There is a type declaration, I rememberd, in Ada, that > > does not allow any object of the type to be declared. > > I think the type should be along the lines below. Is > > this correct? > > > > Then, a function that nominally returns objects of > > this type should be impossible to call. Is this right, > > too? > > > > generic > > type T(<>) is limited private; -- gen. arg. type > > > > package What is > > > > type Void (<>) is private; > > > > function Impossible (X : T) return Void; > > > > private > > > > package Inner is > > type Void (<>) is private; > > private > > type Void is record > > null; > > end record; > > end Inner; > > > > type Void is new Inner.Void; > > > > end What; > > > > (If current Ada could still pass by reference in both call > > direction and return direction, then I'd have added *limited* > > to the Voids' declarations. Without it, a body of Impossible > > is closer to becoming possible by using Convention => Ada > > together with an 'Address clause on a Result object. I think.) > > Before Ada 95 or Ada 2005 it would have been a package > spec that had the following (with P1,P2,etc. being valid types): > > type Not_Objects_Just_for_Parameters is limited private; > function Return_A_Corresponding_Value(p1:t1;p2:t2;etc...) > return Not_Objects_Just_for_Parameters; > procedure Force_Call_Of_Function_1 > (Function_Call:Not_Objects_Just_for_Parameters; > Other_Param3:p3;etc...); > procedure Force_Call_Of_Function_2 > (Function_Call:Not_Objects_Just_for_Parameters; > Other_Param4:p4;etc...); > > I miss that way of forcing/ensuring new execution of some > code as a prerequisite of use of a subprogram. ;-( > Being able to hang on to the result of such a function > by using renames wrecks this usage. Oh, I think maybe (<>) had to be used also on the type definition just like you had.