comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Preventing private procedure visibility being made public through extension
Date: Wed, 24 May 2017 21:06:39 -0700 (PDT)
Date: 2017-05-24T21:06:39-07:00	[thread overview]
Message-ID: <e9d5050e-1046-4f8a-92e0-feded33f7a50@googlegroups.com> (raw)
In-Reply-To: <ofvkhq$2vq$1@franka.jacob-sparre.dk>

On Monday, May 22, 2017 at 5:17:47 PM UTC-4, Randy Brukardt wrote:
> "Jere" wrote in message 
> ...
> > Definitely.  I am also worried about someone copying the access
> > value and holding onto it past the lifetime of the object. I try
> > to avoid Access types when I can.  I wish there was someway to
> > actually pass a limited type as a function return that didn't
> > involve build in place that can initialize.  I just want to be
> > able to return the limited object out temporarily to access it:
> 
> That's what generalized references are for. See 4.1.5 in the RM.
> 
>                         Randy.

That's a good point. I did end up playing with this and getting
an example working.  After going through Jeffrey's example, I
ended up scrapping the access types altogether, but I do need
to learn to leverage this more in cases where access types 
are necessary.

Side question:

If I have a type (Gnoga'ish example):

type View_Base_Type is new Element_Type with private; --taggeed
type View_Type is new View_Base_Type with private;
procedure Create
  (View   : in out View_Type;
   Parent : in out Base_Type'Class;
   ID     : in     String := "");

-- Excuse any typos, this is hand typed code

And then I extend it:

   type My_Type is new View_Base_Type with private;
   procedure Create
     (Obj    : in out My_Type;
      Parent : in out Window_Type'Class; -- derived from Base_Type'Class
      ID     : in     String := "");

private

   type My_Type is new View_Type with null record;

Sometimes if I subtype or extend My_Type, I get the ambiguous
calls to Create issue due to the inherited Create function
from View_Type.

Since the extension of View_Type was private (I publicly 
extended View_Base_Type), should there still be an 
ambiguity between the Create procedures?  My new
one shouldn't be an override and since the extension
to View_Type is private, it shouldn't be callable
(I'm not in a child package, this would be just
some other unrelated package subtyping or extending
My_Type).  I get that before my extension was public
so making the Create procedure private wasn't an
option, but I had hoped with the full view being
private it wouldn't cause the ambiguity.  I realize
in code that could view the private section the issue
might still be there, but this wouldn't be a package
that can see the private section.


  reply	other threads:[~2017-05-25  4:06 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 17:33 Preventing private procedure visibility being made public through extension Jere
2017-05-20 20:13 ` AdaMagica
2017-05-20 21:55   ` Jere
2017-05-20 20:32 ` Dmitry A. Kazakov
2017-05-20 22:51   ` Jere
2017-05-21  0:51     ` Jere
2017-05-21  9:16       ` Chris Moore
2017-05-21 22:55         ` Jere
2017-05-21  8:44     ` Dmitry A. Kazakov
2017-05-21 12:19       ` J-P. Rosen
2017-05-21 12:53         ` Dmitry A. Kazakov
2017-05-21 20:06       ` Jere
2017-05-21 21:07         ` Dmitry A. Kazakov
2017-05-21 22:28           ` Jere
2017-05-22  8:52             ` Dmitry A. Kazakov
2017-05-22 13:33               ` AdaMagica
2017-05-22 13:43           ` AdaMagica
2017-05-22 21:17         ` Randy Brukardt
2017-05-25  4:06           ` Jere [this message]
2017-05-25 19:39             ` Randy Brukardt
2017-05-25 22:53               ` Jere
2017-05-25 22:57                 ` Jere
2017-05-26 20:46                 ` Randy Brukardt
2017-05-26 22:35                   ` Simon Wright
2018-05-20 11:22                     ` Simon Wright
2018-05-20 12:03                       ` Jere
2017-05-26 22:58                   ` Jeffrey R. Carter
2017-05-30 21:15                     ` Randy Brukardt
2017-06-02  1:07                       ` Jere
2017-06-02  7:31                         ` Dmitry A. Kazakov
2017-06-02  8:09                         ` Mark Lorenzen
2017-06-02 11:31                         ` Simon Wright
2017-05-22 21:12   ` Randy Brukardt
2017-05-23  7:38     ` Dmitry A. Kazakov
2017-05-21 18:14 ` Robert Eachus
2017-05-21 20:21   ` Jere
2017-05-21 21:09     ` Jeffrey R. Carter
2017-05-21 22:46       ` Jere
2017-05-22 21:24         ` Jeffrey R. Carter
2017-05-25  3:45           ` Jere
2017-05-21 21:20     ` Dmitry A. Kazakov
2017-05-21 21:45       ` 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