comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Limited_Controlled, orthogonality and related issues
Date: 19 Jan 2007 08:46:47 -0800
Date: 2007-01-19T08:46:47-08:00	[thread overview]
Message-ID: <1169225207.629809.167650@a75g2000cwd.googlegroups.com> (raw)
In-Reply-To: qOSdnfM_csoy6i3YnZ2dnUVZ_vShnZ2d@megapath.net

Randy Brukardt wrote:
> "Maciej Sobczak" <no.spam@no.spam.com> wrote in message
> news:eoned5$663$1@cernne03.cern.ch...
> ...
> > In conclusion, my decision to make T and S controlled appeared to not be
> > orthogonal to the rest of the package.
> >
> > What are your thoughts about this?
>
> It's dubious to have two abstractions in the same package. It's a nice
> simplification compared to other languages, but it's usually better to have
> fewer types in one package rather than more. If T and S were in different
> packages, this problem wouldn't happen. Note that one of the packages could
> be nested or a child, and that would still have the visibility on the
> private part.
>
> Something like:
>
> package Root is
>    type S is limited private;
> ...
> end Root;
>
> package Root.Child is
>    type T is limited private;
>    procedure Do_Something (A : T, B : S);
> ...
> end Root.Child;

Yep, I hadn't thought of that.  And if you use nested inside of child
packages, you could do something like this:

package Root is
    type S is limited private;
    package Inner is
         type T is limited private;
    end Inner;
    subtype T is Inner.T;
    procedure Do_Something (A : T; B : S);
    ...

Now Do_Something isn't a primitive operator on T so there's no 3.9.2
error.  Whether this is "appropriate" or not, I can't tell without
knowing more about the exact types and operations involved.  For the
examples I can think of that I've worked with, S might be some sort of
container type, T might be an iterator to help search through selected
objects in S, and Do_Something might be a routine that returns
successive elements of S that meet some criteria.  In a case like that,
Do_Something probably "belongs" inside the Inner package.  But there
are probably other cases where you would prefer to have Do_Something
outside the Inner package.  It's hard to say without knowing any
details.  But the point is, you can use a construct like this to avoid
the "multiple dispatch" error, and this solution will still let you
implement S and T any way you want in the private part---as opposed to
making S and T part of the same package which prevents you from
implementing both of them as tagged types.

                              -- Adam




  reply	other threads:[~2007-01-19 16:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18  9:24 Limited_Controlled, orthogonality and related issues Maciej Sobczak
2007-01-18 12:00 ` Ludovic Brenta
2007-01-18 12:33   ` AW: " Grein, Christoph (Fa. ESG)
2007-01-18 16:25   ` Robert A Duff
2007-01-18 17:02 ` Adam Beneschan
2007-01-18 17:16   ` Adam Beneschan
2007-01-19  1:02     ` Robert A Duff
2007-01-19  7:38       ` Maciej Sobczak
2007-01-19  9:05     ` Dmitry A. Kazakov
2007-01-19 17:04       ` Adam Beneschan
2007-01-19  1:01   ` Robert A Duff
2007-01-19  9:57   ` Stephen Leake
2007-01-18 19:03 ` Jeffrey Carter
2007-01-19  7:48 ` Randy Brukardt
2007-01-19 16:46   ` Adam Beneschan [this message]
2007-01-19 15:29 ` Robert A Duff
2007-01-19 16:31   ` Dmitry A. Kazakov
2007-01-19 16:36     ` Robert A Duff
2007-01-19 18:26       ` Dmitry A. Kazakov
2007-01-19 20:17         ` Robert A Duff
2007-01-20 10:14           ` Dmitry A. Kazakov
2007-01-20 14:44             ` Robert A Duff
replies disabled

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