mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Rename overloaded operators (add underscores)
* add suffix unary operators * add _! operator * _._ and _&_ operator overloading * allow calling function references with _! and access variables with _._ * rename . method operator to ! * various cleaning & improvements Documentation will follow at some point.
This commit is contained in:
parent
d5b1a9f225
commit
9bd9759115
16 changed files with 350 additions and 178 deletions
|
|
@ -1,7 +1,7 @@
|
|||
$ -(a, b)
|
||||
$ _-_(a, b)
|
||||
@"generic minus"
|
||||
|
||||
$ -(a::string, b::string)
|
||||
$ _-_(a::string, b::string)
|
||||
@a + " minus " + b
|
||||
|
||||
{2-5}
|
||||
|
|
|
|||
7
test/tests/binop assignement.ans
Normal file
7
test/tests/binop assignement.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:c = 1
|
||||
|
||||
{c}
|
||||
|
||||
~ c += 2
|
||||
|
||||
{c}
|
||||
22
test/tests/binop assignement.lua
Normal file
22
test/tests/binop assignement.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
local _={}
|
||||
_[9]={}
|
||||
_[8]={}
|
||||
_[7]={tags=_[9],text="3"}
|
||||
_[6]={tags=_[8],text="1"}
|
||||
_[5]={_[7]}
|
||||
_[4]={_[6]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"text",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "1"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "3"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -4,19 +4,19 @@
|
|||
|
||||
1,2: {l}
|
||||
|
||||
~ l.insert(3)
|
||||
~ l!insert(3)
|
||||
|
||||
1,2,3: {l}
|
||||
|
||||
§ a
|
||||
|
||||
~ l.insert(4)
|
||||
~ l!insert(4)
|
||||
|
||||
1,2,3,4: {l}
|
||||
|
||||
§ b
|
||||
|
||||
~ l.insert(5)
|
||||
~ l!insert(5)
|
||||
|
||||
1,2,3,4,5: {l}
|
||||
|
||||
|
|
|
|||
13
test/tests/function reference chain call.ans
Normal file
13
test/tests/function reference chain call.ans
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
$ fn
|
||||
@1
|
||||
|
||||
$ add(x)
|
||||
@x+2
|
||||
|
||||
:c = &fn
|
||||
|
||||
{c!}
|
||||
|
||||
{fn!add}
|
||||
|
||||
{c!!add}
|
||||
30
test/tests/function reference chain call.lua
Normal file
30
test/tests/function reference chain call.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
local _={}
|
||||
_[13]={}
|
||||
_[12]={}
|
||||
_[11]={}
|
||||
_[10]={text="3",tags=_[13]}
|
||||
_[9]={text="3",tags=_[12]}
|
||||
_[8]={text="1",tags=_[11]}
|
||||
_[7]={_[10]}
|
||||
_[6]={_[9]}
|
||||
_[5]={_[8]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "1"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "3"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "3"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
$ f(a)
|
||||
{a}
|
||||
|
||||
~ "ok".f
|
||||
~ "ok"!f
|
||||
|
||||
~ "ok".f()
|
||||
~ "ok"!f()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
$ f(a, b)
|
||||
{a}{b}
|
||||
|
||||
~ "o".f("k")
|
||||
~ "o"!f("k")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
$ f(l...)
|
||||
~ l.len
|
||||
~ l!len
|
||||
:a = 0
|
||||
~ a := l(1)
|
||||
~ l.remove(1)
|
||||
~ l!remove(1)
|
||||
@a + f(l=l)
|
||||
~~
|
||||
@0
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
$ -(f)
|
||||
$ -_(f)
|
||||
@"generic minus"
|
||||
|
||||
$ -(f::string)
|
||||
$ -_(f::string)
|
||||
@"minus "+f
|
||||
|
||||
{-5}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue