aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-03-05 16:40:20 +0800
committerLi Jin <dragon-fly@qq.com>2020-03-05 16:40:20 +0800
commit9b7ea58d16457e1af0ff90c83db27cbc0b1b4c9b (patch)
treef8a335f1ba1d4318d49a3e28c7009a0bf46cb957
parent890fc913737c62c5d7e51636e0535b7b318a0d89 (diff)
downloadyuescript-9b7ea58d16457e1af0ff90c83db27cbc0b1b4c9b.tar.gz
yuescript-9b7ea58d16457e1af0ff90c83db27cbc0b1b4c9b.tar.bz2
yuescript-9b7ea58d16457e1af0ff90c83db27cbc0b1b4c9b.zip
update readme.
-rw-r--r--README.md64
1 files changed, 63 insertions, 1 deletions
diff --git a/README.md b/README.md
index 4d56a33..9b42edd 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,69 @@ 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* Multi-line comment. 45* Move old `export` statement functions to `global` statement to match the `local` statement.
46
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:
48```Moonscript
49-- file 'Config.moon'
50export default {flag:1, value:"x"}
51
52-- file 'Utils.moon'
53export map = (items, func)-> [func item for item in *items]
54export filter = (items, func)-> [item for item in *items when func item]
55
56-- file 'main.moon'
57import 'Utils' as {:map, :filter}
58```
59Compiles to:
60```Lua
61-- file 'Config.moon'
62local _module_0 = nil
63_module_0 = {
64 flag = 1,
65 value = "x"
66}
67return _module_0
68
69-- file 'Utils.moon'
70local _module_0 = { }
71local map
72map = function(items, func)
73 local _accum_0 = { }
74 local _len_0 = 1
75 for _index_0 = 1, #items do
76 local item = items[_index_0]
77 _accum_0[_len_0] = func(item)
78 _len_0 = _len_0 + 1
79 end
80 return _accum_0
81end
82_module_0["map"] = map
83local filter
84filter = function(items, func)
85 local _accum_0 = { }
86 local _len_0 = 1
87 for _index_0 = 1, #items do
88 local item = items[_index_0]
89 if func(item) then
90 _accum_0[_len_0] = item
91 _len_0 = _len_0 + 1
92 end
93 end
94 return _accum_0
95end
96_module_0["filter"] = filter
97return _module_0
98
99-- file 'main.moon'
100do
101 local _obj_0 = require('Utils')
102 map, filter = _obj_0.map, _obj_0.filter
103end
104```
105
106* Add multi-line comment support.
107
46* Usage for symbol `\` to escape new line. Will compile codes: 108* Usage for symbol `\` to escape new line. Will compile codes:
47```Moonscript 109```Moonscript
48str = --[[ 110str = --[[