comp.lang.ada
 help / color / mirror / Atom feed
* Re: What does this statement do?
@ 2001-11-15 13:45 Gautier Write-only-address
  0 siblings, 0 replies; 4+ messages in thread
From: Gautier Write-only-address @ 2001-11-15 13:45 UTC (permalink / raw)
  To: comp.lang.ada

>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

Are you sure there is a possible ambiguity ? You have the right
to change the name of one 'N' to check this! Try compiling it
(e.g. with the ICC compiler...).

____________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/index.htm#Ada

NB: Do not answer to sender address, visit the Web site!
    Ne r�pondez pas � l'exp�diteur, visitez le site ouaibe!


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




^ permalink raw reply	[flat|nested] 4+ messages in thread
* What does this statement do?
@ 2001-11-14 23:29 Adam Beneschan
  2001-11-15  7:49 ` Preben Randhol
  2001-11-15 15:32 ` Matthew Heaney
  0 siblings, 2 replies; 4+ messages in thread
From: Adam Beneschan @ 2001-11-14 23:29 UTC (permalink / raw)


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;



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

end of thread, other threads:[~2001-11-15 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-15 13:45 What does this statement do? Gautier Write-only-address
  -- strict thread matches above, loose matches on Subject: below --
2001-11-14 23:29 Adam Beneschan
2001-11-15  7:49 ` Preben Randhol
2001-11-15 15:32 ` Matthew Heaney

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