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,af291903d8d84b0c,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-14 15:29:01 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: adam@irvine.com (Adam Beneschan) Newsgroups: comp.lang.ada Subject: What does this statement do? Date: 14 Nov 2001 15:29:01 -0800 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 63.206.153.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1005780541 32594 127.0.0.1 (14 Nov 2001 23:29:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 14 Nov 2001 23:29:01 GMT Xref: archiver1.google.com comp.lang.ada:16550 Date: 2001-11-14T23:29:01+00:00 List-Id: Question for Ada gurus: In the following program, what should happen with the statement marked HERE? (a) Z is set to the value of the local variable N (b) Func is called recursively, and Z is set to the component N of the function result (c) The compiler rejects the statement as ambiguous -- thanks, Adam with Text_IO; use Text_IO; procedure Test is type Rectype is record M : integer; N : integer; end record; Result : Rectype; Recursive : boolean := false; function Func return Rectype is N : integer; X : integer; procedure Inner (Z : out integer) is begin Z := Func.N; -- <======== HERE end Inner; begin N := 1; if Recursive then return (M => 2, N => 3); else Recursive := true; Inner (X); return (M => X, N => X); end if; end Func; begin Result := Func; Put_Line (integer'image (Result.M) & ", " & integer'image (Result.N)); end Test;