From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7916caeb194e9cc2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-12 14:42:05 PST Newsgroups: comp.lang.ada From: Ted Dennison Sender: usenet@www.newsranger.com References: <3ad5ecf3$0$191$456d72a3@news.skynet.be> Subject: Re: Problem with intertask comm Message-ID: Date: Thu, 12 Apr 2001 21:38:33 GMT NNTP-Posting-Host: 209.208.22.130 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 987111513 209.208.22.130 (Thu, 12 Apr 2001 17:38:33 EDT) NNTP-Posting-Date: Thu, 12 Apr 2001 17:38:33 EDT Organization: http://www.newsranger.com Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!news.litech.org!news.ems.psu.edu!newsfeed.stanford.edu!feed.textport.net!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!news.bnb-lp.com!newsranger.com!www.newsranger.com!not-for-mail Xref: supernews.google.com comp.lang.ada:6841 Date: 2001-04-12T21:38:33+00:00 List-Id: In article <3ad5ecf3$0$191$456d72a3@news.skynet.be>, Tom De Muer says... >I'm doing the same assignment as Pieter Thysebaert who posted a message some >days ago but I came across another problem: > >"The prefix to 'ACCESS shall not be statically deeper than that of the >expected type, Continuing" .. >** ** patient_data_a : aliased Patient_Data := (id => 1, my_monitor => >monitor_machine_a'access); ** ** > patient_a : PatientTask(info_for_patient => patient_data_a'access); The problem is more or less what the error message says it is. However, the message is written in LRM-eese. I'll try to translate. Your pointed-to object (the type of monitor_machine_a) is declared inside a subprogram somewhere. That means that the object will cease to exist when that subprogram exits. If that happens, any pointers to that object will suddenly be pointing to unallocated (or worse, allocated for other purposes) memory. That would clearly be a Bad Thing. The language would like to prevent that from happening, by creating rules that make that impossible. Restricting what objects you can copy it into wouldn't work, as that would force the compiler to track the flow of that value through your code. So instead it restricts the *type* of objects you can copy that value into. Specificly, you can't copy that value into an object whose type was declared at a higher scope than the object being pointed to (and thus might exist when the object itself no longer does). To get around this, you can do one of the following: o Move the declaration of Patient_Data_A into a higher scope. o Move the declaration of the type that the Info_For_Patient field uses into a lower scope. o Use 'Unchecked_Access instead of 'Access. Note that if you use this option you must be able to certify that the object can't possibly ever be used after it has gone out of scope. Your instructor might still not be happy about it. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com