From: John B. Matthews on
In article <op.u76nzoymvwnd5a(a)garhos>,
Hibou57 (Yannick Duchêne) <yannick_duchene(a)yahoo.fr> wrote:

> Le Sun, 14 Feb 2010 13:35:47 +0100, John B. Matthews
> <nospam(a)nospam.invalid> a écrit:
> > Type A_Type has its own private part, and this seems more comparable to
> > the declaration of protected type B_Type. Is there any reason to make
> > A_Type more opaque?
> >
> Well, let say first I don't like the idea of designing with a
> compiler bug is mind, and secondly, this is not to be part of a
> public part (I don't really like private stuff in public part). When
> I know a mostly clean workaround, that's Ok, but I do not like this
> one.
> TBH, as was trying (as explained in the initial post), to workaround
> another bug when I meet this one. The interesting point to me, is
> that you get the same, so it is not just my compiler. This means for
> me I should report the bug to AdaCore (as you seem to have confirmed
> the bug).

I wish I could claim to understand it well enough to say one way or the
other. Given the desired declaration,

    package P is
       type A_Type is limited private;
    private
       protected type A_Type is
       private
          Spy : Spies.Instance_Type
            (Client_Name => new String'("P.A_Type"));
       end;
    end P;

is "protected type A_Type" a valid completion of "type A_Type is limited
private;" or is that irrelevant?

> I thank you for the test you've made :)

You're welcome; thank you for an interesting example.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: Adam Beneschan on
On Feb 15, 12:23 pm, "John B. Matthews" <nos...(a)nospam.invalid> wrote:
> In article <op.u76nzoymvwnd5a(a)garhos>,
>  Hibou57 (Yannick Duchêne) <yannick_duch...(a)yahoo.fr> wrote:
>
>
>
>
>
> > Le Sun, 14 Feb 2010 13:35:47 +0100, John B. Matthews  
> > <nos...(a)nospam.invalid> a écrit:
> > > Type A_Type has its own private part, and this seems more comparable to
> > > the declaration of protected type B_Type. Is there any reason to make
> > > A_Type more opaque?
>
> > Well, let say first I don't like the idea of designing with a
> > compiler bug  is mind, and secondly, this is not to be part of a
> > public part (I don't  really like private stuff in public part). When
> > I know a mostly clean workaround, that's Ok, but I do not like this  
> > one.
> > TBH, as was trying (as explained in the initial post), to workaround  
> > another bug when I meet this one. The interesting point to me, is
> > that you get the same, so it is not just  my compiler. This means for
> > me I should report the bug to AdaCore (as you  seem to have confirmed
> > the bug).
>
> I wish I could claim to understand it well enough to say one way or the
> other. Given the desired declaration,
>
>     package P is
>        type A_Type is limited private;
>     private
>        protected type A_Type is
>        private
>           Spy : Spies.Instance_Type
>             (Client_Name => new String'("P.A_Type"));
>        end;
>     end P;
>
> is "protected type A_Type" a valid completion of "type A_Type is limited
> private;" or is that irrelevant?

Yes, it's a valid completion.

For finalization, it doesn't matter whether a type is private or not.
The finalizations that need to be performed on an object need to be
done regardless of whether the full view of the type is visible at any
particular point. So if finalization takes place as expected when the
protected type is public, but doesn't take place when it's private,
that's a clear indication that the compiler has blown it.

-- Adam
From: Hibou57 (Yannick Duchêne) on
Le Mon, 15 Feb 2010 21:23:19 +0100, John B. Matthews
<nospam(a)nospam.invalid> a écrit:
> is "protected type A_Type" a valid completion of "type A_Type is limited
> private;" or is that irrelevant?
Nice reaction (you've asked the good question).

The way you've worded this question, I guess you have an RM close to
hands, so I will give you an answer using formal references :

A short foreword to this reply : the answer to this question is not really
explicit in the RM, and your question mostly get an implied answer (not
explicit one), but you'll still understand.

[ARM 7.3(4)] says :
> A private_type_declaration or private_extension_declaration declares
> a partial view of the type; such a declaration is allowed only as a
> declarative_item of the visible part of a package, and it requires a
> completion, which shall be a full_type_declaration that occurs as a
> declarative_item of the private part of the package.
The completion you've talked about ...

Then [ARM 3.2.1(3)] says :
> full_type_declaration ::=
> type defining_identifier [known_discriminant_part] is
> type_definition;
> | task_type_declaration
> | protected_type_declaration
Protected type declarations allowed as full type declaration, which as the
latter said, is what (the full type declaration) is expected as the
completion of a partial view. So, so far, protected types allowed here.

Then after again [ARM 7.3(6/2)] says :
> [...] If the partial view is nonlimited, then the full view shall be
> nonlimited. If a tagged partial view is limited, then the full view
> shall be limited. [...]
Here comes the implicit answer : it only requires that if a if the partial
view is non-limited, the full-view must not be limited (otherwise, this
would be contradictory). The partial view here is limited, so the
completion may be either limited or none limited if the type completion is
non-tagged, or required to be limited, if the type is tagged.

Protected type are a bit a special things : they are not tagged type which
you can inherit from, but they can implement interface abstract types. But
don't bother other it, and look next, you will understand why this seeming
ambiguity about the tagged/non-tagged status of a protected type, does not
imply an ambiguous answer here.

Finally [ARM 7.5(3/2,4/2)] says :
> A type is limited if it is a descendant of one of the following:
> * a type with the reserved word limited, synchronized, task, or
> protected in its definition;
So whatever you consider protected type as being tagged or non-tagged, as
they are limited by definition, they can be the completion/full-definition
of a type whose public view is limited.

As you see, the core answer is mainly provided, implicitly (as an implied
consequence) in [ARM 7.3(6/2)]

> You're welcome; thank you for an interesting example.
You're welcome too

--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just
not lucky
From: John B. Matthews on
In article <op.u76wltl8hgxj9a(a)garhos>,
Hibou57 (Yannick Duchêne) <yannick_duchene(a)yahoo.fr> wrote:

> > is "protected type A_Type" a valid completion of "type A_Type is limited
> > private;" or is that irrelevant?
> Nice reaction (you've asked the good question).
>
> The way you've worded this question, I guess you have an RM close to
> hands, so I will give you an answer using formal references :

[ARM 3.2.1(3)]<http://www.adaic.com/standards/05rm/html/RM-3-2-1.html>
[ARM 7.3(4)]<http://www.adaic.com/standards/05rm/html/RM-7-3.html>
[ARM 7.3(6/2)]<http://www.adaic.com/standards/05rm/html/RM-7-3.html>
[ARM 7.5(3/2,4/2)]<http://www.adaic.com/standards/05rm/html/RM-7-5.html>

Thanks, both. I was looking at [ARM 3.11.1] "Completions of
Declarations" and overlooked [ARM 3.2.1] "Type Declarations".

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>