From 949166b7db8ff195ce6f1d8d1fa34c242d267af1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 9 Aug 2023 10:17:57 +0800 Subject: update version and docs. --- CHANGELOG.md | 13 +++++++++++++ doc/docs/doc/README.md | 24 +++++++++++++++++++++++- src/yuescript/yue_compiler.cpp | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95ae614..0cd6dc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ 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. +## v0.18.1 + +### Added Features + +* Implemented '...' for variable declaration within scope using anonymous functions. + ```moonscript + ok, ... = fn! + if ok + print select '#', ... + print select 1, ... + ``` +* Added close-variables support for Lua version targets below 5.4. + ## v0.17.10 ### Added Features diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 4c8ac87..7e4aa22 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -1181,6 +1181,28 @@ print "OK" +## Varargs Assignment + +You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. +```moonscript +list = {1, 2, 3, 4, 5} +fn = (ok) -> ok, table.unpack list +ok, ... = fn true +count = select '#', ... +first = select 1, ... +print ok, count, first +``` + +
+list = {1, 2, 3, 4, 5}
+fn = (ok) -> ok, table.unpack list
+ok, ... = fn true
+count = select '#', ...
+first = select 1, ...
+print ok, count, first
+
+
+ ## Whitespace Yuescript is a whitespace significant language. You have to write some code block in the same indent with space **' '** or tab **'\t'** like function body, value list and some control blocks. And expressions containing different whitespaces might mean different things. Tab is treated like 4 space, but it's better not mix the use of spaces and tabs. @@ -1299,7 +1321,7 @@ catch err ## Attributes -Syntax support for Lua 5.4 attributes. But you can still use `const` declaration and get constant check working when targeting Lua versions below 5.4. +Syntax support for Lua 5.4 attributes. And you can still use both the `const` and `close` declaration and get constant check and scoped callback working when targeting Lua versions below 5.4. ```moonscript const a = 123 diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 6644ca5..ab35364 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -74,7 +74,7 @@ static std::unordered_set Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.18.0"sv; +const std::string_view version = "0.18.1"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { -- cgit v1.2.3-55-g6feb