comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: prefix of attribute has deeper level than allocator type
Date: Mon, 20 Aug 2001 14:36:14 GMT
Date: 2001-08-20T14:36:14+00:00	[thread overview]
Message-ID: <yf9g7.7867$2u.57139@www.newsranger.com> (raw)
In-Reply-To: 3B7DF879.5755DC02@ida.his.se

In article <3B7DF879.5755DC02@ida.his.se>, Michael Andersson says...
>What does the following error message mean?
>prefix of attribute has deeper level than allocator type
>
>What I'm trying to do is to dynamically create a terrain like this:
>type Terrain(HeaderFileFileName : access String) is new
>Limited_Controlled with private;
>.
>.
>.
>T := new Terrain(Str'Access); (This is where I get the error
>message)

We just had a thread about this Friday. 'Access /= 'Unchecked_Access. That means
there *are* checks that happen when you do a 'Access. In particular, it will
check to see that the *type* of the object you are assigning into is not
longer-lived (based on the scope of its declaration) than the object you are
taking the 'Access of. The type in this case is implicitly declared when Terrain
is declared. Thus Str has to be declared at the same scope (or a higher scope)
than Terrain. Alternatively, you can use 'Unchecked_Access. In that case there
will be no check, and it will be your full responsitibilty to ensure that "Str"
will always exist as long as the terrain object you just dynamicly allocated
exists. 

If Str isn't declared at the library level (in a package body or spec), then
odds are it *will* go out of scope during the lifetime of your
dynamicly-allocated object, and the compiler acutally caught an error here.  

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



      reply	other threads:[~2001-08-20 14:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-18  5:09 prefix of attribute has deeper level than allocator type Michael Andersson
2001-08-20 14:36 ` Ted Dennison [this message]
replies disabled

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