comp.lang.ada
 help / color / mirror / Atom feed
From: Stanley Allen <sallen@ghg.net>
Subject: Self-referential 'Access
Date: 1998/04/20
Date: 1998-04-20T00:00:00+00:00	[thread overview]
Message-ID: <353B4DC4.EB3650F4@ghg.net> (raw)


For the language lawyers:

Below is a library-level package spec that
I have tried to compile with both GNAT (3.10p)
and ObjectAda (7.1) on my Win95/AMD586 box.

------------ cellar.ads -----------
package Cellar is

    type Cell;

    type List is access all Cell;

    type Cell is limited record
        Contents : String (1 .. 10);
        Next_Cell : List := Cell'Access;  --line 9
        Prev_Cell : List := Cell'Access;  --line 10
    end record;

end Cellar;
-----------------------------------

Both compilers claim that the uses of the
'Access attribute are not valid because they
violate the rules concerning depth of
accessability.

GNAT says this:
    cellar.ads:9:29 object has deeper accessibility
    level than access type
    [and the same for line 10]

ObjectAda says:
    cellar.ads: Error: line 9 col 29 LRM:3.10.2(28),
        The prefix to 'ACCESS shall not be statically
        deeper than that of the expected type
    [and the same for line 10]

(Note: I have not attempted to declare a Cell
object in any other unit; the errors are generated
strictly from the compilation of this package spec.)

The rules for "statically deeper" levels are given
under RM95:3.10.2(17).  The only rule that seems
like it might apply here is RM95:3.10.2(21).

So, I have a few questions.

1) Are the compilers in error, or is this code?

2) If this code is in error, is it because of the
   rule at paragraph (21)?

3) If so, does this rule really make sense?
   It does not seem right that these 'Access
   references should be considered "deeper" than
   the access type.

4) Should the rule disallow only non-limited
   records?

Stanley Allen
mailto:sallen@ghg.net




             reply	other threads:[~1998-04-20  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-20  0:00 Stanley Allen [this message]
1998-04-20  0:00 ` Self-referential 'Access Tucker Taft
1998-04-20  0:00 ` Matthew Heaney
1998-04-20  0:00   ` Jerry van Dijk
replies disabled

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