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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,faeb0c2550699cee X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-16 22:28:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!teaser.fr!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: controlled initialization Date: Tue, 17 Dec 2002 07:20:17 +0100 (MET) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 1040106482 42523 137.194.161.2 (17 Dec 2002 06:28:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 17 Dec 2002 06:28:02 +0000 (UTC) Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: WLdGElaTHCul1hV8i/aoLw== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk X-Reply-To: "Grein, Christoph" List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:31941 Date: 2002-12-17T07:20:17+01:00 > Interesting. So (remembering that I don't know Ada) the following > would be illegal as well? If it is, is there a way to do what the > code obviously intends? Do I understand the issue correctly, that > is that MakeT could use O? > > package P is > type T is private; > O : constant T; > private > type T is new Controlled with null record; > function MakeT return T; > O : constant T := MakeT; > end P; Absolutely correct, MakeT is not elaborated when you call it here. So this code is not illegal, but will raise an exception. And why would you want to call a function here? A record initialisation can easily be used because you have full visibility of all components. In a contrived case like the following, you would have a point. But then simply define your complicated function in a child package, use an Elaborate_Body pragma and call the function to initilise O. Here you are - no problem. package P is type T is private; O : constant T; private type T is new Controlled with record Comp: Some_Type; end record; O : constant T := (Controlled with Comp => Some very complicated code here); end P;