aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/metatable.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-03-03 21:31:01 +0800
committerLi Jin <dragon-fly@qq.com>2021-03-03 21:33:37 +0800
commit1df786307c1983b8ce693e3916081a8bcd4e95ae (patch)
tree6c7aeb2198d825877fd3d179c394b7a5c1f06a17 /spec/inputs/metatable.yue
parent66168b112b707172b9035edf8c1daed469781e06 (diff)
downloadyuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.gz
yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.bz2
yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.zip
add new metatable syntax for issue #41, fix reusing local variable issue, update built-in Lua.
Diffstat (limited to 'spec/inputs/metatable.yue')
-rw-r--r--spec/inputs/metatable.yue43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue
new file mode 100644
index 0000000..6f7b418
--- /dev/null
+++ b/spec/inputs/metatable.yue
@@ -0,0 +1,43 @@
1a = close: true, close#: => print "out of scope"
2b = add#: (left, right)-> right - left
3c = key1: true, :add#, key2: true
4
5close _ = close#: -> print "out of scope"
6
7d, e = a.close, a.close#
8
9f = a\close# 1
10a.add# = (x, y)-> x + y
11
12do
13 {:new, :close#, close#: closeA} = a
14 print new, close, closeA
15
16do
17 local *
18 x, \
19 {:new, :var, :close#, close#: closeA}, \
20 :num, :add#, :sub# \
21 = 123, a.b.c, func!
22
23x.abc, a.b.# = 123, {}
24func!.# = mt, extra
25a, b.c.#, d, e = 1, mt, "abc"
26
27is_same = a.#.__index == a.index#
28
29--
30a.# = __index: tb
31a.#.__index = tb
32a.index# = tb
33--
34
35mt = a.#
36
37tb\func #list
38tb\func#list
39tb\func# list
40
41import "module" as :index#, newindex#:setFunc
42
43nil