Guest User

Untitled

a guest
Jul 16th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Ximp
  2. ====
  3.  
  4. The following code shows the Ximp language output for some specific input, showing some of the benefits from using such a nice language.
  5.  
  6. Defining something
  7. ------------------
  8.  
  9. an Account
  10. is positive? { @amount >= 0 }
  11. withdraw { (amount is (@amount - value)) }
  12.  
  13. my_account is Account (amount is 1000)
  14. my_account is positive?
  15. new_account is (withdraw from my_account (value is 300))
  16. new_account is my_account after withdraw (value is 300)
  17.  
  18.  
  19. Another type:
  20.  
  21. a Manager
  22.  
  23. Ximping a type
  24. --------------
  25.  
  26. ximp my Account
  27. with a Manager
  28.  
  29. Creating something
  30. ------------------
  31.  
  32. my_account is Account(owner is "guilherme", amount is 50)
  33.  
  34. paulo is Manager(name is "Paulo Silveira")
  35.  
  36. my_account's manager is paulo
  37.  
  38. Output
  39. ------
  40.  
  41. print my_account's manager's name
  42.  
  43. Paulo Silveira
  44.  
  45. Easy to extend
  46. --------------
  47.  
  48. The following examples show how it is easy to define new macros.
  49.  
  50. Input
  51. -----
  52.  
  53. yo, tell me my_account's manager's name
  54.  
  55. Carlos
  56.  
  57. State
  58. -----
  59.  
  60. my_account, sup dawg?
  61.  
  62. my owner is guilherme, amount is 50, manager's name is Carlos
  63.  
  64. Comments
  65. --------
  66.  
  67. Hmmm "if you want to contribute, just fork me!"
  68.  
  69. whatever
Add Comment
Please, Sign In to add comment