comp.lang.ada
 help / color / mirror / Atom feed
* prefix of attribute has deeper level than allocator type
@ 2001-08-18  5:09 Michael Andersson
  2001-08-20 14:36 ` Ted Dennison
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Andersson @ 2001-08-18  5:09 UTC (permalink / raw)


Hi!
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)

Need your help, please!
//Michael



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

* Re: prefix of attribute has deeper level than allocator type
  2001-08-18  5:09 prefix of attribute has deeper level than allocator type Michael Andersson
@ 2001-08-20 14:36 ` Ted Dennison
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Dennison @ 2001-08-20 14:36 UTC (permalink / raw)


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



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

end of thread, other threads:[~2001-08-20 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-18  5:09 prefix of attribute has deeper level than allocator type Michael Andersson
2001-08-20 14:36 ` Ted Dennison

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