From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.0 required=3.0 tests=BAYES_20,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ac8:4906:: with SMTP id e6mr22653720qtq.360.1600251823967; Wed, 16 Sep 2020 03:23:43 -0700 (PDT) X-Received: by 2002:a05:620a:3d0:: with SMTP id r16mr22096270qkm.129.1600251823541; Wed, 16 Sep 2020 03:23:43 -0700 (PDT) Path: 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.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 16 Sep 2020 03:23:43 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=92.56.166.72; posting-account=C8J7NQoAAAD_ybGY7--QIRi6KpLjoH1Z NNTP-Posting-Host: 92.56.166.72 References: <27269975-58eb-407b-98ca-344bee6894d2n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <28481dfd-7127-4106-bcfd-f085ffbf228fn@googlegroups.com> Subject: Re: Visibility issue From: Daniel Injection-Date: Wed, 16 Sep 2020 10:23:43 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:60159 List-Id: El mi=C3=A9rcoles, 16 de septiembre de 2020 a las 9:14:23 UTC+2, Dmitry A. = Kazakov escribi=C3=B3: > That is OK, but the hidden part needs to be constructed in some way. Your= =20 > requirements are silent about how. There exist only two possibilities,=20 > it is either generated internally or else provided by the client=20 > externally in some form, e.g. as parameters for the constructing function= . The Requirements are not constraining how to construct the API handle in bo= th sides (Client, API and Internal). Im lucky with that. :) Let's try to set and construct all hidden part details from Internal side, = not from user side. I will add Just a public Registering type because it wi= ll be a limited pool of callbacks and users needs to Identify them. What needs to know the user? -the implementation of the callback procedure it self -A number that identify this procedure (they are constrained to lets say = just 12 procedures) What needs to know and access the Internal package side? - A hidden part of Handle_type with dirty details about buffer pointers = that needs to be set before triggering the procedure. - The callback procedure from a pool implemented in the same Internal pac= kage hierarchy that previously set the user. Let me expose a simplification using the 3 parts: Client, API, Implementing= . -- USER SIDE: --- procedure mycallback6 (S: in out Handle) is begin ---call to public Handle functions ada.text_io.Put_Line(S.public_for_users); end mycallback6; procedure Initialize is MyUserCallbackRegister : Register_type :=3D (mycallback'Access , 6); begin null; end Initialize; -- API SIDE: --------- package API.Callbacks --Manage the callback: type Handle is tagged private type pointer_to_Procedure is access procedure (Self : API.CAllbacks.Handle = ); function public_for_users(S: in out Handle) return string; --Manage registering the callback type Register_type is private; function Register_Callback ( cp: CallbackProcedure , ID: Natural ) return R= egister_type ; private type Handle is tagged record Usefull_for_Implementing_side : Pointer_To_buffer_type; Register : Register_type;=20 end record; end package API.Callbacks; type Register_type is Natural; with Internal.Pool; package body API.Callbacks is function Register_Callback ( cp: CallbackProcedure , ID: Natural ) return R= egister_type is begin Internal.CallbacksPool.Set( cp, ID); return Register_type'(ID); end Register_Callback; ----- IMPLEMENTING SIDE: -------- with API.Callbacks; with Buffer_Stuff; package body Internal.CallbacksPool is task body InteranalCaller6 is MyInternalHandle : API.Handle; callbackprocedure: API.CallbackProcedure :=3D Get_from_pool_of_callbacks (6= ); begin -- I need to set here the private part of MyInternalHandle defined in API.H= andle before triggering and I Can't. :( -- If I want to set this private part with a function, the only way is to m= ake it public and accessible for users too. MyInternalHandle :=3D ???? --Later I trigger: callbackprocedure (MyInternalHandle); end InteranalCaller6 ; end Internal.CallbacksPool; ----------------------------------- So, here comes my options: -- Set MyInternalHandle with a public function visible to users in API and = tryng to explain them with education that they can't use it. -- Implement the Internal details in API package hierarchy extending API.Ha= ndle -- Saying to who give me this requirements I can't do it using Ada (and pro= bably any other language) -- Some other magic idea to implement this totally different :)