diff options
author | Li Jin <dragon-fly@qq.com> | 2022-07-14 03:42:21 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-07-14 03:42:21 +0800 |
commit | c6946ca162911036a19cc7c5deadb6d8c127755e (patch) | |
tree | e728f31693d7fb1da3b5fca7f4ac5656392cf1f3 | |
parent | 3159a45de9e691ad758dcbc933446f61b7ae1940 (diff) | |
download | yuescript-0.13.4.tar.gz yuescript-0.13.4.tar.bz2 yuescript-0.13.4.zip |
update doc and changelog.v0.13.4
-rw-r--r-- | CHANGELOG.md | 60 | ||||
-rwxr-xr-x | doc/docs/doc/README.md | 16 |
2 files changed, 70 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 12baa60..d106df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -2,6 +2,66 @@ | |||
2 | 2 | ||
3 | The implementation for the original Moonscript language 0.5.0 can be found in the `0.5.0` branch of Yuescript. The Moonscript with fixes and new features is in the main branch of Yuescript. Here are the changelogs for each Yuescript version. | 3 | The implementation for the original Moonscript language 0.5.0 can be found in the `0.5.0` branch of Yuescript. The Moonscript with fixes and new features is in the main branch of Yuescript. Here are the changelogs for each Yuescript version. |
4 | 4 | ||
5 | ## v0.13.4 | ||
6 | |||
7 | ### Added Features | ||
8 | |||
9 | * Added update syntax support for `var //= 5`. | ||
10 | * Added metamethod syntax support for class block. | ||
11 | ```moonscript | ||
12 | class Foo | ||
13 | new: (x) => @x = x | ||
14 | mul#: (y) => @x * y | ||
15 | ["abc"]#: 123 | ||
16 | :add | ||
17 | :add# | ||
18 | ``` | ||
19 | * Added support `with` block access with `[key]` syntax. | ||
20 | ```moonscript | ||
21 | with tb | ||
22 | [1] = [2]\func! | ||
23 | print [3] | ||
24 | with [abc] | ||
25 | [4] = 1 | ||
26 | [] = "abc" | ||
27 | ``` | ||
28 | |||
29 | * Added table pattern matching syntax. | ||
30 | ```moonscript | ||
31 | items = | ||
32 | * x: 100 | ||
33 | y: 200 | ||
34 | * width: 300 | ||
35 | height: 400 | ||
36 | |||
37 | for item in *items | ||
38 | switch item | ||
39 | when :x, :y | ||
40 | print "Vec2 #{x}, #{y}" | ||
41 | when :width, :height | ||
42 | print "size #{width}, #{height}" | ||
43 | ``` | ||
44 | |||
45 | ### Fixed Issues | ||
46 | |||
47 | * Fix `import X as {_}` generates invalid Lua code. | ||
48 | * Fix attribute syntax with line decorator compiles to unexpected codes. | ||
49 | ```moonscript | ||
50 | const a = 1 if true | ||
51 | ``` | ||
52 | now compiles to: | ||
53 | ```lua | ||
54 | local a <const> = (function() | ||
55 | if true then | ||
56 | return 1 | ||
57 | end | ||
58 | end)() | ||
59 | ``` | ||
60 | * Fix continue in `repeat` loop gives invalid code. | ||
61 | * Fix variables with attributes "const" and "close" should both get constant check in compiler. | ||
62 | * Fix ambiguous syntax starting with `[[`. Expressions starting with `[[` will now be always treated like raw strings other than nested list comprehensions. | ||
63 | * Fix module can export both macros and normal values. The macro exporting module can now only allow macro definition, macro importing and macro expansion in place for better compiler performance. | ||
64 | |||
5 | ## v0.10.17 | 65 | ## v0.10.17 |
6 | 66 | ||
7 | ### Added Features | 67 | ### Added Features |
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index ef00c23..90cb309 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md | |||
@@ -2343,19 +2343,23 @@ for item in *items | |||
2343 | You can use default values to optionally destructure the table for some fields. | 2343 | You can use default values to optionally destructure the table for some fields. |
2344 | 2344 | ||
2345 | ```moonscript | 2345 | ```moonscript |
2346 | item = x: 100 | 2346 | item = {} |
2347 | |||
2348 | {pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') | ||
2347 | 2349 | ||
2348 | switch item | 2350 | switch item |
2349 | when {:x, :y = 200} | 2351 | when {pos: {:x = 50, :y = 200}} |
2350 | print "Vec2 #{x}, #{y}" -- table matching will pass | 2352 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass |
2351 | ``` | 2353 | ``` |
2352 | <YueDisplay> | 2354 | <YueDisplay> |
2353 | <pre> | 2355 | <pre> |
2354 | item = x: 100 | 2356 | item = {} |
2357 | |||
2358 | {pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') | ||
2355 | 2359 | ||
2356 | switch item | 2360 | switch item |
2357 | when {:x, :y = 200} | 2361 | when {pos: {:x = 50, :y = 200}} |
2358 | print "Vec2 #{x}, #{y}" -- table matching will pass | 2362 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass |
2359 | </pre> | 2363 | </pre> |
2360 | </YueDisplay> | 2364 | </YueDisplay> |
2361 | 2365 | ||