Guest User

Untitled

a guest
Feb 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // Demonstration of allocator references
  2.  
  3. fn malloc(size usize) *uni i8;
  4. fn free(ptr *u8);
  5. alloc lex {
  6. fn allocate(size usize) *lex {
  7. malloc(size) as *lex;
  8. }
  9. fn dealias(self *lex) {
  10. free(self as *u8);
  11. }
  12. }
  13.  
  14. fn main() {
  15. imm reffloat = &lex 3.4d;
  16. *reffloat = *reffloat + 2.0d;
  17. printANumber(reffloat);
  18. }
  19.  
  20. fn print(str &u8);
  21. fn printFloat(n f64);
  22.  
  23. fn printANumber(nbr &f64) {
  24. print("The number is: ");
  25. printFloat(*nbr);
  26. print("\n");
  27. }
Add Comment
Please, Sign In to add comment