Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. -- main.adb
  2. with MyProc;
  3.  
  4. procedure test is
  5. type MyFloat is new Float with Default_Value => 10.0;
  6. package P is new MyProc (MyFloat);
  7. Var : P.Bla;
  8. Var2 : MyFloat := P.Stuff (Var);
  9. begin
  10. null;
  11. end test;
  12.  
  13. -- MyProc.ads
  14. generic
  15. type MyTypeWithDefault is private;
  16. package MyProc is
  17. type Bla is tagged private;
  18. function Stuff (Self : Bla) return MyTypeWithDefault;
  19. private
  20. type Bla is tagged record
  21. Data : MyTypeWithDefault;
  22. end record;
  23. end MyProc;
  24.  
  25. -- MyProc.adb
  26. package body MyProc is
  27. function Stuff (Self : Bla) return MyTypeWithDefault is
  28. begin
  29. return Self.Data;
  30. end Stuff;
  31. end MyProc;
  32.  
  33. generic
  34. type MyTypeWithDefault is private;
  35. Default_Value : in MyTypeWithDefault;
  36. package MyProc is
  37. type Bla is tagged private;
  38. function Stuff (Self : Bla) return MyTypeWithDefault;
  39. private
  40. type Bla is tagged record
  41. Data : MyTypeWithDefault:= Default_Value;
  42. end record;
  43. end MyProc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement