comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Claude Rostaing <00120260a@gmail.com>
Subject: Re: limited agregate and limited components default initialization
Date: Tue, 3 Apr 2018 11:18:10 -0700 (PDT)
Date: 2018-04-03T11:18:10-07:00	[thread overview]
Message-ID: <3a9d9cbf-87aa-41a4-89b5-b4a02ebcb748@googlegroups.com> (raw)
In-Reply-To: <e1e73838-2e45-4f53-9cbf-e28e85100fd1@googlegroups.com>

Talking about limited aggregates, how to make the exemple below with protected types work ? It should be pretty much the same as what I already did, yet...
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 
      procedure CHANGE (V: Natural);
   private
      Private_var: Natural := D1; 
   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 => V)); -- 9

   protected body Essai is
      procedure CHANGE (V: natural) is
      begin
         PRIVATE_VAR := 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 object as an argument, so the profile wouldn't be the same, so a renaming can 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 through setting its discriminants. Discriminants who would serve to set the default value with the constructor, so they must be hidden from the user.

I must confess I never used anything protected types before... I thought the use would be more intuitive ?

  parent reply	other threads:[~2018-04-03 18:18 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-31 23:36 limited agregate and limited components default initialization Jean-Claude Rostaing
2018-04-01  0:52 ` Jere
2018-04-01  1:12   ` Jere
2018-04-01  1:16   ` Jean-Claude Rostaing
2018-04-01  1:34     ` Jere
2018-04-01  2:07       ` Jean-Claude Rostaing
2018-04-01  2:40         ` Jere
2018-04-01  2:54           ` Jere
2018-04-01  3:14         ` Jere
2018-04-01  3:31           ` Jere
2018-04-01  9:32         ` Jacob Sparre Andersen
2018-04-01 12:58           ` Jean-Claude Rostaing
2018-04-01 13:33 ` Dmitry A. Kazakov
2018-04-01 15:46   ` Jean-Claude Rostaing
2018-04-01 15:53     ` Jean-Claude Rostaing
2018-04-01 15:54       ` Jean-Claude Rostaing
2018-04-01 21:31       ` Dmitry A. Kazakov
2018-04-02  3:44         ` Randy Brukardt
2018-04-02 11:25           ` Jean-Claude Rostaing
2018-04-02 12:11             ` Dmitry A. Kazakov
2018-04-02 12:15             ` Jean-Claude Rostaing
2018-04-02 21:37             ` Randy Brukardt
2018-04-03 17:01               ` Jeffrey R. Carter
2018-04-05 10:27           ` AdaMagica
2018-04-02  3:42     ` Randy Brukardt
2018-04-01 22:52 ` Jean-Claude Rostaing
2018-04-01 23:36   ` Jean-Claude Rostaing
2018-04-01 23:39     ` Jean-Claude Rostaing
2018-04-02 18:19       ` Jere
2018-04-02 18:50         ` Dmitry A. Kazakov
2018-04-02 19:46           ` Jere
2018-04-02 19:59             ` Dmitry A. Kazakov
2018-04-02 21:03               ` Jean-Claude Rostaing
2018-04-03  8:14                 ` Dmitry A. Kazakov
2018-04-03  1:27             ` Dennis Lee Bieber
2018-04-02 22:39     ` Robert I. Eachus
2018-04-03 18:18 ` Jean-Claude Rostaing [this message]
2018-04-03 18:28   ` Jean-Claude Rostaing
2018-04-03 19:18   ` Jeffrey R. Carter
2018-04-03 19:25     ` Jean-Claude Rostaing
2018-04-03 20:12       ` Jeffrey R. Carter
2018-04-03 22:37         ` Jean-Claude Rostaing
2018-04-04  2:18   ` Jere
replies disabled

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