comp.lang.ada
 help / color / mirror / Atom feed
* Re: Access1 := new Accessed_Type; Access1 = Access2 ...?!
@ 2004-11-29  6:51 Christoph Karl Walter Grein
  2004-11-29 17:54 ` Florian Haag
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Karl Walter Grein @ 2004-11-29  6:51 UTC (permalink / raw)
  To: comp.lang.ada

> State_Access := new Vessel_State_Type;
> State_Access.All.Previous_State := Parent_State;
> if State_Access /= null then

this if statement comes too late:
If State_Access = null, then the preceding assignment to State_Access.All.Previous_State would raise an exception: Constraint_Error, because the dereference State_Access.All is impossible.

>  if State_Access = State_Access.All.Previous_State then
>    raise MyEx;
>  end if;
> end if;

__________________________________________________________
Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
weltweit telefonieren! http://freephone.web.de/?mc=021201




^ permalink raw reply	[flat|nested] 6+ messages in thread
* Access1 := new Accessed_Type; Access1 = Access2 ...?!
@ 2004-11-27 12:12 Florian Haag
  2004-11-27 13:58 ` Jeff C r e e.m
  2004-11-27 20:42 ` Jeffrey Carter
  0 siblings, 2 replies; 6+ messages in thread
From: Florian Haag @ 2004-11-27 12:12 UTC (permalink / raw)


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






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

end of thread, other threads:[~2004-11-29 17:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-29  6:51 Access1 := new Accessed_Type; Access1 = Access2 ...?! Christoph Karl Walter Grein
2004-11-29 17:54 ` Florian Haag
  -- strict thread matches above, loose matches on Subject: below --
2004-11-27 12:12 Florian Haag
2004-11-27 13:58 ` Jeff C r e e.m
2004-11-28  9:56   ` Florian Haag
2004-11-27 20:42 ` Jeffrey Carter

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