diff options
author | Li Jin <dragon-fly@qq.com> | 2022-04-25 16:17:41 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-04-25 16:17:41 +0800 |
commit | cfbabdc579795cb34f3b601ce1aee4443951e2ba (patch) | |
tree | 6b83e440f1b25cd9fe16325213aeb61eaa628437 | |
parent | 10afeaf30bfe03774c12908235520eebf0c192ee (diff) | |
download | yuescript-cfbabdc579795cb34f3b601ce1aee4443951e2ba.tar.gz yuescript-cfbabdc579795cb34f3b601ce1aee4443951e2ba.tar.bz2 yuescript-cfbabdc579795cb34f3b601ce1aee4443951e2ba.zip |
update Changelog.
-rw-r--r-- | CHANGELOG.md | 206 |
1 files changed, 156 insertions, 50 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c87ff7..4c80a4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -2,6 +2,112 @@ | |||
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.10.15 | ||
6 | |||
7 | ### Fixed Issues | ||
8 | |||
9 | * Fix ambiguous syntax caused by argument table block. | ||
10 | * Fix an issue using import as table destructuring with meta methods. | ||
11 | * Fix a case combining the use of existential operator and metatable operator. | ||
12 | * Raise error when use existential operator in the left part of an assignment. | ||
13 | * Fix the way update assignment is implemented to reduce unnecessary table indexing. | ||
14 | * Fix more cases that global variables are not being cached. | ||
15 | * Fix Yuescript loader insertion order. | ||
16 | * Fix Yuescript not found error messages. | ||
17 | |||
18 | ### Added Features | ||
19 | |||
20 | * Builtin macros `$FILE`, `$LINE` to get the source file names and code line numbers. | ||
21 | * Table appending operator. | ||
22 | ```moonscript | ||
23 | tb = {} | ||
24 | tb[] = 1 | ||
25 | ``` | ||
26 | Compiles to: | ||
27 | ```lua | ||
28 | local tb = { } | ||
29 | tb[#tb + 1] = 1 | ||
30 | ``` | ||
31 | * Class mixing function by keyword `using`. | ||
32 | ```moonscript | ||
33 | class A using B | ||
34 | -- If B is a Yuescript class object (which has a field named __base), | ||
35 | -- only fields that are not meta method will be added to class object A | ||
36 | -- If B is a plain table, all the fields will be added to class object A | ||
37 | -- so that you can change the behavior of Yuescript class' meta method __index. | ||
38 | ``` | ||
39 | * Try catch syntax. | ||
40 | ```moonscript | ||
41 | try | ||
42 | func 1, 2, 3 | ||
43 | catch err | ||
44 | print yue.traceback err | ||
45 | |||
46 | success, result = try func 1, 2, 3 | ||
47 | ``` | ||
48 | Compiles to: | ||
49 | ```lua | ||
50 | xpcall(function() | ||
51 | return func(1, 2, 3) | ||
52 | end, function(err) | ||
53 | return print(yue.traceback(err)) | ||
54 | end) | ||
55 | local success, result = pcall(func, 1, 2, 3) | ||
56 | ``` | ||
57 | * Add nil coalescing operator. | ||
58 | ```moonscript | ||
59 | local a, b, c | ||
60 | a = b ?? c | ||
61 | a ??= false | ||
62 | ``` | ||
63 | Compiles to: | ||
64 | ```lua | ||
65 | local a, b, c | ||
66 | if b ~= nil then | ||
67 | a = b | ||
68 | else | ||
69 | a = c | ||
70 | end | ||
71 | if a == nil then | ||
72 | a = false | ||
73 | end | ||
74 | ``` | ||
75 | |||
76 | * Add a global variable "arg" for Yuescipt tool CLI execution. | ||
77 | * Add placeholder support for list destructuring. | ||
78 | ```moonscript | ||
79 | {_, b, _, d} = tb | ||
80 | ``` | ||
81 | Compiles to: | ||
82 | ```lua | ||
83 | local b, d | ||
84 | do | ||
85 | local _obj_0 = tb | ||
86 | b, d = _obj_0[2], _obj_0[4] | ||
87 | end | ||
88 | ``` | ||
89 | * Add table spread syntax. | ||
90 | ```moonscript | ||
91 | copy = {...other} | ||
92 | ``` | ||
93 | Compiles to: | ||
94 | ```lua | ||
95 | local copy | ||
96 | do | ||
97 | local _tab_0 = { } | ||
98 | local _idx_0 = 1 | ||
99 | for _key_0, _value_0 in pairs(other) do | ||
100 | if _idx_0 == _key_0 then | ||
101 | _tab_0[#_tab_0 + 1] = _value_0 | ||
102 | _idx_0 = _idx_0 + 1 | ||
103 | else | ||
104 | _tab_0[_key_0] = _value_0 | ||
105 | end | ||
106 | end | ||
107 | copy = _tab_0 | ||
108 | end | ||
109 | ``` | ||
110 | |||
5 | ## v0.8.5 | 111 | ## v0.8.5 |
6 | 112 | ||
7 | ### Fixed Issues | 113 | ### Fixed Issues |
@@ -12,36 +118,36 @@ The implementation for the original Moonscript language 0.5.0 can be found in th | |||
12 | ### Added Features | 118 | ### Added Features |
13 | 119 | ||
14 | * Nil coalescing operator. | 120 | * Nil coalescing operator. |
15 | ```moonscript | 121 | ```moonscript |
16 | local a, b, c, d | 122 | local a, b, c, d |
17 | a = b ?? c ?? d | 123 | a = b ?? c ?? d |
18 | func a ?? {} | 124 | func a ?? {} |
19 | 125 | ||
20 | a ??= false | 126 | a ??= false |
21 | ``` | 127 | ``` |
22 | Compiles to: | 128 | Compiles to: |
23 | ```lua | 129 | ```lua |
24 | local a, b, c, d | 130 | local a, b, c, d |
25 | if b ~= nil then | 131 | if b ~= nil then |
26 | a = b | 132 | a = b |
27 | else | 133 | else |
28 | if c ~= nil then | 134 | if c ~= nil then |
29 | a = c | 135 | a = c |
30 | else | 136 | else |
31 | a = d | 137 | a = d |
32 | end | 138 | end |
33 | end | 139 | end |
34 | func((function() | 140 | func((function() |
35 | if a ~= nil then | 141 | if a ~= nil then |
36 | return a | 142 | return a |
37 | else | 143 | else |
38 | return { } | 144 | return { } |
39 | end | 145 | end |
40 | end)()) | 146 | end)()) |
41 | if a == nil then | 147 | if a == nil then |
42 | a = false | 148 | a = false |
43 | end | 149 | end |
44 | ``` | 150 | ``` |
45 | 151 | ||
46 | * New metatable syntax. | 152 | * New metatable syntax. |
47 | ```moonscript | 153 | ```moonscript |
@@ -190,7 +296,7 @@ end | |||
190 | return false | 296 | return false |
191 | x.name\EndsWith "(Clone)" | 297 | x.name\EndsWith "(Clone)" |
192 | \Destroy! | 298 | \Destroy! |
193 | 299 | ||
194 | origin.transform.root.gameObject | 300 | origin.transform.root.gameObject |
195 | \Parents!\Descendants! | 301 | \Parents!\Descendants! |
196 | \SelectEnable! | 302 | \SelectEnable! |
@@ -315,7 +421,7 @@ end | |||
315 | return 'abc' | 421 | return 'abc' |
316 | end | 422 | end |
317 | end)() | 423 | end)() |
318 | ``` | 424 | ``` |
319 | 425 | ||
320 | 426 | ||
321 | 427 | ||
@@ -395,24 +501,24 @@ end | |||
395 | export macro config = (debugging = true)-> | 501 | export macro config = (debugging = true)-> |
396 | global debugMode = debugging == "true" | 502 | global debugMode = debugging == "true" |
397 | "" | 503 | "" |
398 | 504 | ||
399 | export macro asserts = (cond)-> | 505 | export macro asserts = (cond)-> |
400 | debugMode and "assert #{cond}" or "" | 506 | debugMode and "assert #{cond}" or "" |
401 | 507 | ||
402 | export macro assert = (cond)-> | 508 | export macro assert = (cond)-> |
403 | debugMode and "assert #{cond}" or "#{cond}" | 509 | debugMode and "assert #{cond}" or "#{cond}" |
404 | 510 | ||
405 | $config! | 511 | $config! |
406 | 512 | ||
407 | -- file 'main.mp' | 513 | -- file 'main.mp' |
408 | import 'macro' as {:$config, :$assert, :$asserts} | 514 | import 'macro' as {:$config, :$assert, :$asserts} |
409 | 515 | ||
410 | macro and = (...)-> "#{ table.concat {...}, ' and ' }" | 516 | macro and = (...)-> "#{ table.concat {...}, ' and ' }" |
411 | 517 | ||
412 | $asserts item ~= nil | 518 | $asserts item ~= nil |
413 | $config false | 519 | $config false |
414 | value = $assert item | 520 | value = $assert item |
415 | 521 | ||
416 | if $and f1!, f2!, f3! | 522 | if $and f1!, f2!, f3! |
417 | print "OK" | 523 | print "OK" |
418 | ``` | 524 | ``` |
@@ -421,7 +527,7 @@ end | |||
421 | -- file 'macro.mp' | 527 | -- file 'macro.mp' |
422 | local _module_0 = { } | 528 | local _module_0 = { } |
423 | return _module_0 | 529 | return _module_0 |
424 | 530 | ||
425 | -- file 'main.mp' | 531 | -- file 'main.mp' |
426 | assert(item ~= nil) | 532 | assert(item ~= nil) |
427 | local value = item | 533 | local value = item |
@@ -459,11 +565,11 @@ From the original Moonscript compiler: | |||
459 | ```Moonscript | 565 | ```Moonscript |
460 | -- file 'Config.mp' | 566 | -- file 'Config.mp' |
461 | export default {flag:1, value:"x"} | 567 | export default {flag:1, value:"x"} |
462 | 568 | ||
463 | -- file 'Utils.mp' | 569 | -- file 'Utils.mp' |
464 | export map = (items, func)-> [func item for item in *items] | 570 | export map = (items, func)-> [func item for item in *items] |
465 | export filter = (items, func)-> [item for item in *items when func item] | 571 | export filter = (items, func)-> [item for item in *items when func item] |
466 | 572 | ||
467 | -- file 'main.mp' | 573 | -- file 'main.mp' |
468 | import 'Config' as {:flag, :value} | 574 | import 'Config' as {:flag, :value} |
469 | import 'Utils' as {:map, :filter} | 575 | import 'Utils' as {:map, :filter} |
@@ -477,7 +583,7 @@ From the original Moonscript compiler: | |||
477 | value = "x" | 583 | value = "x" |
478 | } | 584 | } |
479 | return _module_0 | 585 | return _module_0 |
480 | 586 | ||
481 | -- file 'Utils.mp' | 587 | -- file 'Utils.mp' |
482 | local _module_0 = { } | 588 | local _module_0 = { } |
483 | local map | 589 | local map |
@@ -507,7 +613,7 @@ From the original Moonscript compiler: | |||
507 | end | 613 | end |
508 | _module_0["filter"] = filter | 614 | _module_0["filter"] = filter |
509 | return _module_0 | 615 | return _module_0 |
510 | 616 | ||
511 | -- file 'main.mp' | 617 | -- file 'main.mp' |
512 | local flag, value | 618 | local flag, value |
513 | do | 619 | do |
@@ -547,7 +653,7 @@ Fix issues in original Moonscript compiler: | |||
547 | |> filter((x)-> x > 4) | 653 | |> filter((x)-> x > 4) |
548 | |> reduce(0, (a,b)-> a + b) | 654 | |> reduce(0, (a,b)-> a + b) |
549 | 655 | ||
550 | 656 | ||
551 | do | 657 | do |
552 | (data) <- http.get "ajaxtest" | 658 | (data) <- http.get "ajaxtest" |
553 | body[".result"]\html data | 659 | body[".result"]\html data |
@@ -582,11 +688,11 @@ Fix issues in original Moonscript compiler: | |||
582 | * Existential operator support. Generate codes from: | 688 | * Existential operator support. Generate codes from: |
583 | ```Moonscript | 689 | ```Moonscript |
584 | func?! | 690 | func?! |
585 | 691 | ||
586 | x = tab?.value | 692 | x = tab?.value |
587 | 693 | ||
588 | print abc?["hello world"]?.xyz | 694 | print abc?["hello world"]?.xyz |
589 | 695 | ||
590 | if print and x? | 696 | if print and x? |
591 | print x | 697 | print x |
592 | ``` | 698 | ``` |
@@ -715,11 +821,11 @@ Fix issues in original Moonscript compiler: | |||
715 | ```Moonscript | 821 | ```Moonscript |
716 | with leaf | 822 | with leaf |
717 | .world 1,2,3 | 823 | .world 1,2,3 |
718 | 824 | ||
719 | with leaf | 825 | with leaf |
720 | g = .what.is.this | 826 | g = .what.is.this |
721 | print g | 827 | print g |
722 | 828 | ||
723 | for x in *something | 829 | for x in *something |
724 | print x | 830 | print x |
725 | ``` | 831 | ``` |