comp.lang.ada
 help / color / mirror / Atom feed
From: James Alan Farrell <anonymous@anonymous.com>
Subject: Question on operator overloading
Date: Thu, 07 Apr 2005 12:24:32 -0400
Date: 2005-04-07T12:24:32-04:00	[thread overview]
Message-ID: <9bna519q4shdp4vrjlap1pbeps4u8565m8@4ax.com> (raw)

Hi all,
I'm looking at ARM 6.6 (and 4.5).  I don't see anything that disallows
in/out or out parameters when overloading an operator.  When I try to
use an in/out parameter in gnat, I get an error.  Is this disallowed?
Could there be compilers that allow it?

I'm not trying to do this.  I'm working on software to analyze Ada
programs (using ASIS) and need to cover all possible bases.

Thanks,
James Alan Farrell


with Ada.Text_IO;
use  Ada.Text_IO;

 procedure Proc1 is

      type MyInt is new Integer range 0 .. 1000;

      function "+" (Left : MyInt; Right : in out MyInt) return MyInt
is
      begin
         return MyInt(Integer(Left) + Integer(Right) + 3);
      end;

      A, B, Y : MyInt;

   begin -- proc1
      A := 1;
      B := 2;
      Y := A + B;
      Put_Line(Integer'Image(Integer(Y)));
   end Proc1;
end mod1;

=====

$> gnatmake main
gcc -c mod1.adb
mod1.adb:10:35: functions can only have "in" parameters
gnatmake: "mod1.adb" compilation error


(main simply declares a procedure that calls Proc1)



             reply	other threads:[~2005-04-07 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-07 16:24 James Alan Farrell [this message]
2005-04-07 16:33 ` Question on operator overloading Georg Bauhaus
2005-04-07 16:57   ` James Alan Farrell
2005-04-07 18:26 ` Martin Krischik
replies disabled

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