Advertisement
tinyevil

Untitled

May 9th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. -- everyone can use debug
  2. public scope debug
  3. -- function in the debug scope...
  4. in debug function SetPrintExtraInfo(flag:bool)
  5.  
  6. -- to use it, we must explicitly use the debug scope:
  7. function Foo()
  8. SetPrintExtraInfo(true) -- fails
  9.  
  10. debug::SetPrintExtraInfo(true) -- ok
  11. end
  12.  
  13. function Bar()
  14. use debug
  15.  
  16. SetPrintExtraInfo(true) -- ok
  17. end
  18.  
  19. use debug
  20. function Bar()
  21. SetPrintExtraInfo(true) -- ok
  22. end
  23.  
  24. in debug function Bar()
  25. SetPrintExtraInfo(true) -- ok
  26. end
  27.  
  28. -- kinda namespacy
  29.  
  30.  
  31. -- only this module can provide details, but everyone can use it
  32. in this_module(put), public(use) scope details
  33.  
  34. -- private "submodule" with only one exported function
  35. scope with
  36. global var state:i64
  37.  
  38. in public function Random()
  39. ....
  40. end
  41. end
  42.  
  43.  
  44. in public type HttpResponse with
  45. -- only this module can construct,
  46. -- everyone can still destruct (inherited)
  47. in this_module(construct) case Response(code:i32) with
  48. -- inherited
  49. case Success with
  50. case OK
  51. case Created
  52. case Accepted
  53. end
  54.  
  55. case Redirection(url:string) with
  56. case Permanent
  57. case Temporary
  58. end
  59.  
  60. case ClientError
  61. case BadRequest
  62. case NotFound
  63. case Forbidden
  64. end
  65.  
  66. case ServerError
  67. case Internal
  68. case BadGateway
  69. end
  70.  
  71. -- everyone can get or set, inherited
  72. field headers:List[{string,string}]
  73.  
  74. -- everyone can get, only this module can set
  75. in this_module(set) field body:string
  76. end
  77.  
  78. in this_module(construct) case NetworkError(os_code:string)
  79. in this_module(construct) case Timeout
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement