comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Language lawyer question: access discriminants
Date: Tue, 6 Apr 2010 14:17:04 -0700 (PDT)
Date: 2010-04-06T14:17:04-07:00	[thread overview]
Message-ID: <06e780ef-c171-4037-b96e-f44788ae2bdf@g10g2000yqh.googlegroups.com> (raw)

I'm hoping someone who understands the rules about access discriminant
accessibility level can answer this definitively.  This is a reduced
example of something I found in someone else's code:

package Pack1 is
    type Rec is record
        F1 : Integer;
    end record;
    type Rec2 (D : access Rec) is limited record
        F2 : Integer;
    end record;
    function Func (Param : Integer) return Rec2;
end Pack1;

with Pack1;  use Pack1;
procedure Proc2 is
    A : access Rec;
begin
    A := Func(1).D;   -- LEGAL?
end Proc2;

I think the statement marked LEGAL? is illegal, because of rules
saying that the result of Func is an object inside a nested master
that consists of just the one assignment statement, and the
accessibility level of the access discriminant (Func(1).D) is the
accessibility level of the enclosing object (the temporary object
containing the result of Func), and therefore the accessibility level
of Func(1).D is deeper than that of A.  But the rules are pretty
complex and I'm hoping someone in the know can straighten me out if
I'm wrong.  (And I'm not interested in any replies that say "XYZ
compiler says it's legal".  I need to know what the standard says.)

                                                 -- thanks, Adam



             reply	other threads:[~2010-04-06 21:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06 21:17 Adam Beneschan [this message]
2010-04-07 20:04 ` Language lawyer question: access discriminants Randy Brukardt
2010-04-08  0:21   ` Adam Beneschan
replies disabled

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