comp.lang.ada
 help / color / mirror / Atom feed
* Self-referential 'Access
@ 1998-04-20  0:00 Stanley Allen
  1998-04-20  0:00 ` Matthew Heaney
  1998-04-20  0:00 ` Tucker Taft
  0 siblings, 2 replies; 4+ messages in thread
From: Stanley Allen @ 1998-04-20  0:00 UTC (permalink / 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




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

end of thread, other threads:[~1998-04-20  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-20  0:00 Self-referential 'Access Stanley Allen
1998-04-20  0:00 ` Matthew Heaney
1998-04-20  0:00   ` Jerry van Dijk
1998-04-20  0:00 ` Tucker Taft

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