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.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3821e3559d170f28 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!wns13feed!worldnet.att.net!attbi_s54.POSTED!53ab2750!not-for-mail From: "Jeff C r e e.m" Newsgroups: comp.lang.ada References: <30r96lF34a891U1@uni-berlin.de> Subject: Re: Access1 := new Accessed_Type; Access1 = Access2 ...?! X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response Message-ID: <9K%pd.401802$wV.389499@attbi_s54> NNTP-Posting-Host: 24.147.74.171 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s54 1101563909 24.147.74.171 (Sat, 27 Nov 2004 13:58:29 GMT) NNTP-Posting-Date: Sat, 27 Nov 2004 13:58:29 GMT Organization: Comcast Online Date: Sat, 27 Nov 2004 13:58:30 GMT Xref: g2news1.google.com comp.lang.ada:6551 Date: 2004-11-27T13:58:30+00:00 List-Id: "Florian Haag" wrote in message news:30r96lF34a891U1@uni-berlin.de... > Hi, > I'm quite new to Ada and I hope someone can explain this to me: > I've got the following code: > > Parent_State is assigned some already existing Vessel_State_Type > variable, or null. > > State_Access := new Vessel_State_Type; > State_Access.All.Previous_State := Parent_State; > if State_Access /= null then > if State_Access = State_Access.All.Previous_State then > raise MyEx; > end if; > end if; > > Now, why is MyEx raised? > > Parent_State should refer to an already existent variable, whereas > (I thought) the variable State_Access points to is just created in > the beginning of that block ...? > If the above code does not what I thought it did, how can I > achieve that? ;-) > > TIA > Florian Haag > > > I can't think of any reason why myEx should be raised. Are you sure that is what is happening? Also the .ALLs in you code here are optional. The following code (with the optional .alls) with Text_IO; with Ada.Exceptions; procedure Test_Ex is type Vessel_State_Type; type Access_Vessel_State_Type is access Vessel_State_Type; type Vessel_State_Type is record Previous_State : Access_Vessel_State_Type; end record; Parent_State : Access_Vessel_State_Type := new Vessel_State_Type; State_Access : Access_Vessel_State_Type; MyEx : exception; begin State_Access := new Vessel_State_Type; State_Access.All.Previous_State := Parent_State; if State_Access /= null then if State_Access = State_Access.All.Previous_State then raise MyEx; end if; end if; Text_IO.Put_Line("No problem"); exception when ID : others => Text_IO.Put_Line(Ada.Exceptions.Exception_Name(ID)); end Test_Ex; Prints "No problem" when it runs. So, without seeing more of your code I can not really guess what is happening.