Changeset 68c7062 for doc/theses/fangren_yu_MMath/test.adb
- Timestamp:
- Apr 14, 2025, 9:54:29 AM (6 months ago)
- Branches:
- master
- Children:
- 10ef475
- Parents:
- d9aee90
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/fangren_yu_MMath/test.adb
rd9aee90 r68c7062 16 16 Function Func( V1 : Integer; V2 : Float ) return Float is begin return Float(V1) + V2; end; 17 17 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 19 25 20 26 i : Integer; … … 33 39 type T is private; 34 40 with function "+"( X, Y: T ) return T; 35 function twice( X : T) return T;41 function twice( X : T ) return T; 36 42 37 43 function twice( X: T ) return T is … … 43 49 function float_Twice is new Twice( float, "+" => "+" ); 44 50 45 --generic units cannot be overloaded46 --generic47 --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 is52 --begin53 --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; 55 61 begin 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 56 71 i := Random; 57 72 Print( i ); … … 61 76 Print( s ); 62 77 63 Print( Func( 7 ) );78 Print( Func( V => 7 ) ); 64 79 Print( Func( 7.5 ) ); 65 80 Print( Func( To_Unbounded_String( "abc" ) ) ); 66 81 Print( Func( 3, 3.5 ) ); 82 -- Print( Func( 3, 3 ) ); 67 83 68 84 Grind( X => (Re => 1.0, Im => 1.0) );
Note:
See TracChangeset
for help on using the changeset viewer.