From 4ba4c90e711c6204aa40e38347c5a5a076d9370e Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 23 May 2025 15:07:45 +0800 Subject: Added `-` for implicit object. --- doc/docs/doc/README.md | 63 ++++++++++++++++++++++++++++++---------------- doc/docs/zh/doc/README.md | 64 +++++++++++++++++++++++++++++++---------------- 2 files changed, 84 insertions(+), 43 deletions(-) (limited to 'doc/docs') diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 0853391..58b37c0 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -16,17 +16,17 @@ Yue (月) is the name of moon in Chinese and it's pronounced as [jyɛ]. ### An Overview of YueScript ```moonscript -- import syntax -import "yue" as :p, :to_lua +import p, to_lua from "yue" -- object literals inventory = equipment: - * "sword" - * "shield" + - "sword" + - "shield" items: - * name: "potion" + - name: "potion" count: 10 - * name: "bread" + - name: "bread" count: 3 -- list comprehension @@ -61,17 +61,17 @@ export 🌛 = "月之脚本"
 -- import syntax
-import "yue" as :p, :to_lua
+import p, to_lua from "yue"
 
 -- object literals
 inventory =
   equipment:
-    * "sword"
-    * "shield"
+    - "sword"
+    - "shield"
   items:
-    * name: "potion"
+    - name: "potion"
       count: 10
-    * name: "bread"
+    - name: "bread"
       count: 3
 
 -- list comprehension
@@ -752,34 +752,45 @@ a ??= false
 
 ### Implicit Object
 
-You can write a list of implicit structures that starts with the symbol **\*** inside a table block. If you are creating implicit object, the fields of the object must be with the same indent.
+You can write a list of implicit structures that starts with the symbol **\*** or **-** inside a table block. If you are creating implicit object, the fields of the object must be with the same indent.
+
 ```moonscript
+-- assignment with implicit object
 list =
   * 1
   * 2
   * 3
 
+-- function call with implicit object
 func
   * 1
   * 2
   * 3
 
+-- return with implicit object
+f = ->
+  return
+    * 1
+    * 2
+    * 3
+
+-- table with implicit object
 tb =
   name: "abc"
 
   values:
-    * "a"
-    * "b"
-    * "c"
+    - "a"
+    - "b"
+    - "c"
 
   objects:
-    * name: "a"
+    - name: "a"
       value: 1
       func: => @value + 1
       tb:
         fieldA: 1
 
-    * name: "b"
+    - name: "b"
       value: 2
       func: => @value + 2
       tb: { }
@@ -787,32 +798,42 @@ tb =
 ```
 
 
+-- assignment with implicit object
 list =
   * 1
   * 2
   * 3
 
+-- function call with implicit object
 func
   * 1
   * 2
   * 3
 
+-- return with implicit object
+f = ->
+  return
+    * 1
+    * 2
+    * 3
+
+-- table with implicit object
 tb =
   name: "abc"
 
   values:
-    * "a"
-    * "b"
-    * "c"
+    - "a"
+    - "b"
+    - "c"
 
   objects:
-    * name: "a"
+    - name: "a"
       value: 1
       func: => @value + 1
       tb:
         fieldA: 1
 
-    * name: "b"
+    - name: "b"
       value: 2
       func: => @value + 2
       tb: { }
diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md
index 2968f6e..1dd59a7 100755
--- a/doc/docs/zh/doc/README.md
+++ b/doc/docs/zh/doc/README.md
@@ -16,17 +16,17 @@ Yue(月)是中文中“月亮”的名称。
 ### 月之脚本概览
 ```moonscript
 -- 导入语法
-import "yue" as :p, :to_lua
+import p, to_lua from "yue"
 
 -- 隐式对象
 inventory =
   equipment:
-    * "sword"
-    * "shield"
+    - "sword"
+    - "shield"
   items:
-    * name: "potion"
+    - name: "potion"
       count: 10
-    * name: "bread"
+    - name: "bread"
       count: 3
 
 -- 列表推导
@@ -61,17 +61,17 @@ export 🌛 = "月之脚本"
 
 
 -- 导入语法
-import "yue" as :p, :to_lua
+import p, to_lua from "yue"
 
 -- 隐式对象
 inventory =
   equipment:
-    * "sword"
-    * "shield"
+    - "sword"
+    - "shield"
   items:
-    * name: "potion"
+    - name: "potion"
       count: 10
-    * name: "bread"
+    - name: "bread"
       count: 3
 
 -- 列表推导
@@ -751,67 +751,87 @@ a ??= false
 
 ### 隐式对象
 
-你可以在表格块内使用符号 **\*** 开始编写一系列隐式结构。如果你正在创建隐式对象,对象的字段必须具有相同的缩进。
+你可以在表格块内使用符号 **\*** 或是 **-** 开始编写一系列隐式结构。如果你正在创建隐式对象,对象的字段必须具有相同的缩进。
+
 ```moonscript
+-- 赋值时使用隐式对象
 list =
   * 1
   * 2
   * 3
 
+-- 函数调用时使用隐式对象
 func
   * 1
   * 2
   * 3
 
+-- 返回时使用隐式对象
+f = ->
+  return
+    * 1
+    * 2
+    * 3
+
+-- 表格时使用隐式对象
 tb =
   name: "abc"
 
   values:
-    * "a"
-    * "b"
-    * "c"
+    - "a"
+    - "b"
+    - "c"
 
   objects:
-    * name: "a"
+    - name: "a"
       value: 1
       func: => @value + 1
       tb:
         fieldA: 1
 
-    * name: "b"
+    - name: "b"
       value: 2
       func: => @value + 2
       tb: { }
-
 ```
 
 
+-- 赋值时使用隐式对象
 list =
   * 1
   * 2
   * 3
 
+-- 函数调用时使用隐式对象
 func
   * 1
   * 2
   * 3
 
+-- 返回时使用隐式对象
+f = ->
+  return
+    * 1
+    * 2
+    * 3
+
+-- 表格时使用隐式对象
 tb =
   name: "abc"
 
   values:
-    * "a"
-    * "b"
-    * "c"
+    - "a"
+    - "b"
+    - "c"
 
   objects:
-    * name: "a"
+    - name: "a"
       value: 1
       func: => @value + 1
       tb:
         fieldA: 1
 
-    * name: "b"
+    - name: "b"
       value: 2
       func: => @value + 2
       tb: { }
-- 
cgit v1.2.3-55-g6feb