comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Inheritance question...
Date: 1997/03/24
Date: 1997-03-24T00:00:00+00:00	[thread overview]
Message-ID: <E7K17q.E9D@world.std.com> (raw)
In-Reply-To: 33361956.4F30@pacbell.net


In article <33361956.4F30@pacbell.net>,
Marc Bejerano  <mbejeran@pacbell.net> wrote:
>when I try to create a descendent type in my main procedure I get:
>
>  "type extension at deeper accessibility level than parent"
>
>here's my "simplified" main procedure:
>
>with foo; use foo;
>
>procedure foofoo is
>  type my_bar is new bar1 with record
>    s: string(1..128);
>  end record;

>what am I doing wrong?

Bar1 is declared at library level.  My_Bar is declared one level deeper
-- within a procedure.  This can cause dangling references, and is
therefore not allowed.  You should put My_Bar in a library package, not
inside a procedure.  Basically, "deepness" is a count of how many
procedures, functions, block statements, and tasks you're inside --
packages don't count.

The fact that it's the main procedure is irrelevant -- it's still a
procedure.  Note that in Ada, code can execute after the main procedure
has returned -- namely, library tasks keep going, and if they got their
hands on an object whose tag was My_Bar'Tag, they could reference stuff
that no longer exists.

- Bob




  reply	other threads:[~1997-03-24  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-23  0:00 Inheritance question Marc Bejerano
1997-03-24  0:00 ` Robert A Duff [this message]
1997-03-24  0:00 ` Jerome Desquilbet
1997-03-25  0:00 ` Tucker Taft
replies disabled

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