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.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Received: by 10.107.52.66 with SMTP id b63mr6807942ioa.66.1522779491593; Tue, 03 Apr 2018 11:18:11 -0700 (PDT) X-Received: by 2002:a9d:4807:: with SMTP id c7-v6mr848049otf.1.1522779491164; Tue, 03 Apr 2018 11:18:11 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!k65-v6no3545461ita.0!news-out.google.com!u64-v6ni6954itb.0!nntp.google.com!u184-v6no5340869ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 3 Apr 2018 11:18:10 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.154.190.43; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 82.154.190.43 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3a9d9cbf-87aa-41a4-89b5-b4a02ebcb748@googlegroups.com> Subject: Re: limited agregate and limited components default initialization From: Jean-Claude Rostaing <00120260a@gmail.com> Injection-Date: Tue, 03 Apr 2018 18:18:11 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:51320 Date: 2018-04-03T11:18:10-07:00 List-Id: Talking about limited aggregates, how to make the exemple below with protec= ted types work ? It should be pretty much the same as what I already did, y= et... package P is type Essai (<>) is limited private; function Constructor (v: Natural) return ESSAI; procedure CHANGE (Obj: Essai; V: Natural); private protected type ESSAI (D1: Natural) is=20 procedure CHANGE (V: Natural); private Private_var: Natural :=3D D1;=20 end Essai; end P; package BODY P is -- procedure change(Obj: Essai; V: natural) renames ESSAI.CHANGE; procedure CHANGE (Obj: ESSAI; V: NATURAL) is begin OBJ.CHANGE(V); -- 5 end CHANGE; function CONSTRUCTOR ( V : NATURAL) return ESSAI is (Essai(D1 =3D> V)); -- 9 protected body Essai is procedure CHANGE (V: natural) is begin PRIVATE_VAR :=3D V; end change; end Essai; end P; I get p.adb:5:10: prefix of protected procedure or entry call must be variable p.adb:9:14: invalid prefix in call Actually, I wanted CHANGE to be a renaming of Change, but since Essai here = behave more like a package, the protected operation doesn't its protected o= bject as an argument, so the profile wouldn't be the same, so a renaming ca= n only point to a specific task/protect object's entry. I want to force people to use a constructor on any object of ESSAI type thr= ough setting its discriminants. Discriminants who would serve to set the de= fault value with the constructor, so they must be hidden from the user. I must confess I never used anything protected types before... I thought th= e use would be more intuitive ?