Ignore:
Timestamp:
Apr 14, 2025, 9:54:29 AM (6 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
10ef475
Parents:
d9aee90
Message:

update overload test programs for Ada and swift

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/fangren_yu_MMath/test.adb

    rd9aee90 r68c7062  
    1616        Function Func( V1 : Integer; V2 : Float ) return Float is begin return Float(V1) + V2; end;
    1717       
    18         Function "-"( L, R : Integer ) return Integer is begin return L + (-R); end; --  prevent infinite recusion
     18        subtype Int       is Integer;
     19        J : Int;
     20        Function "-"( L, R : Int ) return Int is begin Put_Line( "X" ); return Integer(L) + (-Integer(R)); end; --  prevent infinite recusion
     21       
     22--      duplicate body for "-" declared at line 20
     23--      subtype SInt is Integer range -10 .. 10;
     24--      Function "-"( L, R : SInt ) return SInt is begin Put_Line( "X" ); return Integer(L) + (-Integer(R)); end; --  prevent infinite recusion
    1925       
    2026        i : Integer;
     
    3339           type T is private;
    3440           with function "+"( X, Y: T ) return T;
    35         function twice(X : T) return T;
     41        function twice( X : T ) return T;
    3642       
    3743        function twice( X: T ) return T is
     
    4349        function float_Twice is new Twice( float, "+" => "+" );
    4450       
    45         -- generic units cannot be overloaded
    46         -- generic
    47         --    type T is private;
    48         --    with function "+"( X, Y: T ) return T;
    49         -- function twice( X : T; Y : T ) return T;
    50         --
    51         -- function twice( X: T; Y : T ) return T is
    52         -- begin
    53         --    Put_Line( "XXX" ); return X + X;   -- The formal operator "*".
    54         -- end twice;
     51--      generic units cannot be overloaded
     52--      generic
     53--        type T is private;
     54--        with function "+"( X, Y: T ) return T;
     55--      function twice( X : T; Y : T ) return T;
     56       
     57--      function twice( X: T; Y : T ) return T is
     58--      begin
     59--        Put_Line( "XXX" ); return X + X;   -- The formal operator "*".
     60--      end twice;
    5561begin
     62   I := 3;
     63   I := 7 - 3;
     64        Print( i );
     65   F := 3.8;
     66   I := 7 - 2;
     67        Print( i );
     68   J := 7 - 3;
     69        Print( j );
     70   
    5671        i := Random;
    5772        Print( i );
     
    6176        Print( s );
    6277       
    63         Print( Func( 7 ) );
     78        Print( Func( V => 7 ) );
    6479        Print( Func( 7.5 ) );
    6580        Print( Func( To_Unbounded_String( "abc" ) ) );
    6681        Print( Func( 3, 3.5 ) );
     82--      Print( Func( 3, 3 ) );
    6783       
    6884        Grind( X => (Re => 1.0, Im => 1.0) );
Note: See TracChangeset for help on using the changeset viewer.