comp.lang.ada
 help / color / mirror / Atom feed
From: Sazonov Cyril <cyril@geol.spb.su>
Subject: Re: What's with GNAT?
Date: 1996/12/27
Date: 1996-12-27T00:00:00+00:00	[thread overview]
Message-ID: <AA4HwmoyZ4@geol.spb.su> (raw)


BwB wrote us:

.................
> the GNAT compiler for the SUN (sorry, I don't know the version--I'm not sure
> they do either!). But the problem seems to come from the conversion of an
> "out" parameter. The GNAT compiler says the statement wil raise
> CONTRAINT_ERROR, and if a program is executed it does indeed raise it. Since
> I am not familiar enough with GNAT, I offered to post this question for them.
..................................
> What are missing about GNAT?
..................................
>      procedure Multiply ( Left, Right : in     Global.Cartesian_Vector;
>                           Result      :    out Global.Cartesian_Vector );
..................................
>
>      procedure Multiply ( Left, Right : in     Global.NED_Vector;
>                           Result      :    out Global.NED_Vector  );
>      begin  -- Multiply
>         Multiply ( Global.Cartesian(Left), Global.Cartesian(Right),
>                    Global.NED_Vector(Result)                         );
> -------------------^^^^^^^^^^^^^^^^^^^^^^^^^
>-------------------- claims it will raise CONSTRAINT_ERROR--and does!
>      end Multiply;

I suppose you are missing about the _language_, but not _GNAT_. It seems me
that the thing is that the reurned result is of Global.Cartesian_Vector type
even though the variable Result is of Global.NED_Vector and the type
conversion is to be done _before_ assignment, perfomed by the result return.
So you are to use an intermediate variable to be able to _get_ the wanted
result and the cjnvert it. For example:

      procedure Multiply ( Left, Right : in     Global.NED_Vector;
                           Result      :    out Global.NED_Vector  );

         INTERIM : Global.Cartesian_Vector;

      begin  -- Multiply
         Multiply ( Global.Cartesian(Left), Global.Cartesian(Right),
                    INTERIM ) ;
         Result := Global.NED_Vector ( INTEGRIM ) ;
      end Multiply;

Happy New Year !

Best wishes from Russia !                             Cyril Sazonov





             reply	other threads:[~1996-12-27  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-27  0:00 Sazonov Cyril [this message]
1996-12-28  0:00 ` What's with GNAT? burnsedbw
  -- strict thread matches above, loose matches on Subject: below --
1996-12-30  0:00 Sazonov Cyril
1996-12-26  0:00 BurnsedBW
replies disabled

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