aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/README.md b/README.md
index ea4c305..42da196 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,48 @@ f!
42 42
43The original Moonscript language 0.5.0 support can be found in the `0.5.0` branch. Moonscript with new features is in the master branch. Here are the new features introduced in MoonPlus. 43The original Moonscript language 0.5.0 support can be found in the `0.5.0` branch. Moonscript with new features is in the master branch. Here are the new features introduced in MoonPlus.
44 44
45* Add macro functions.
46```Moonscript
47-- file 'macro.moon'
48export macro block config = (debugging = true)->
49 global debugMode = debugging == "true"
50 ""
51
52export macro block asserts = (cond)->
53 debugMode and "assert #{cond}" or ""
54
55export macro expr assert = (cond)->
56 debugMode and "assert #{cond}" or "#{cond}"
57
58$config!
59
60-- file 'main.moon'
61import 'macro' as {:$config, :$assert, :$asserts}
62
63macro expr and = (...)->
64 "#{ table.concat {...}, ' and ' }"
65
66$asserts item ~= nil
67$config false
68value = $assert item
69
70if $and f1!, f2!, f3!
71 print "OK"
72```
73 Compiles to:
74```Lua
75-- file 'macro.moon'
76local _module_0 = { }
77return _module_0
78
79-- file 'main.moon'
80assert(item ~= nil)
81local value = item
82if (f1() and f2() and f3()) then
83 print("OK")
84end
85```
86
45* Move old `export` statement functions to `global` statement to match the `local` statement. 87* Move old `export` statement functions to `global` statement to match the `local` statement.
46 88
47* Change `export` statement behavier to support module management. Moon codes with `export` statement can not explicit return values in root scope. And codes with `export default` can export only one value as the module content. Use cases: 89* Change `export` statement behavier to support module management. Moon codes with `export` statement can not explicit return values in root scope. And codes with `export default` can export only one value as the module content. Use cases: