bind expression (:=) instead of let
Some checks failed
Build / build (push) Successful in 10m26s
Test / build (push) Failing after 16m44s

This commit is contained in:
Chuck Smith
2024-03-21 17:43:03 -04:00
parent 66d5453ecc
commit 6282075e66
36 changed files with 425 additions and 583 deletions

View File

@@ -1,2 +1,2 @@
let xs = [1, 2, 3]
xs := [1, 2, 3]
xs[0] + xs[1] + xs[2]

View File

@@ -1,3 +1,3 @@
let x = 1
x := 1
x = 2
x = x + 1

3
testdata/binding.monkey vendored Normal file
View File

@@ -0,0 +1,3 @@
x := 1
y := 2
z := x

View File

@@ -1,4 +1,4 @@
let xs = [1, 2, 3]
xs := [1, 2, 3]
len(xs)
first(xs)
@@ -9,5 +9,5 @@ pop(xs)
len("foo")
let x = input()
x := input()
print(x)

View File

@@ -1,2 +1,2 @@
let f = fn(x) { fn() { x + 1 } }
f := fn(x) { fn() { x + 1 } }
f(2)

View File

@@ -1,2 +1,2 @@
let f = fn(x, y) { x * y };
f := fn(x, y) { x * y };
f(2, 4)

View File

@@ -1,2 +1,2 @@
let d = {"a": 1, "b": 2}
d := {"a": 1, "b": 2}
d["a"] + d["b"]

2
testdata/if.monkey vendored
View File

@@ -1,4 +1,4 @@
let x = 1
x := 1
if (x == 1) {
x = 2
x

3
testdata/let.monkey vendored
View File

@@ -1,3 +0,0 @@
let x = 1
let y = 2
let z = x

View File

@@ -1 +0,0 @@
let n = 2; let x = 0; while (n > 0) { if (n > 1) { x = x + 1 }; n = n - 1; }; x;

View File

@@ -1 +0,0 @@
let n = 2; let x = 0; while (n > 0) { if (n > 1) { x = x + 1 }; let n = n - 1; }; x;

View File

@@ -1 +0,0 @@
let x = 1; if (x == 1) { let x = 2 }

5
testdata/selectors.monkey vendored Normal file
View File

@@ -0,0 +1,5 @@
d := {"foo": 1, "bar": 2}
assert(d.foo == 1, "d.foo != 1")
assert(d.bar == 2, "d.bar != 2")
assert(d.bogus == null, "d.bogus != null")

View File

@@ -1,2 +1,2 @@
let s = "hello"
s := "hello"
s + " " + "world"