Guest User

Module Objects in E

a guest
May 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.81 KB | None | 0 0
  1. /*********************************************
  2.  * Storage.E                                 *
  3.  *********************************************/
  4. private var value : int;
  5.  
  6. export fn get() -> int {
  7.     return value;
  8. }
  9. export fn set(i : value) {
  10.     value := i;
  11. }
  12.  
  13. /*********************************************
  14.  * Module-User-A.E                           *
  15.  *********************************************/
  16. import "Storage";
  17.  
  18. void main()
  19. {
  20.     Storage.set(10);
  21.     // ...
  22.     print_int(Storage.get());
  23. }
  24.  
  25.  
  26.  
  27. /*********************************************
  28.  * Module-User-A.E                           *
  29.  *********************************************/
  30. import "Storage" as StorageA;
  31. import "Storage" as StorageB;
  32.  
  33. void main()
  34. {
  35.     StorageA.set(10);
  36.     StorageB.set(20);
  37.     // ...
  38.     print_int(StorageA.get(), StorageB.get());
  39. }
Advertisement
Add Comment
Please, Sign In to add comment