comp.lang.ada
 help / color / mirror / Atom feed
* Language lawyer question: access discriminants
@ 2010-04-06 21:17 Adam Beneschan
  2010-04-07 20:04 ` Randy Brukardt
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Beneschan @ 2010-04-06 21:17 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-08  0:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-06 21:17 Language lawyer question: access discriminants Adam Beneschan
2010-04-07 20:04 ` Randy Brukardt
2010-04-08  0:21   ` Adam Beneschan

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