Better scoping in repeat/for, lazy expression (no implicit import yet)

This commit is contained in:
Dmitry Boulytchev 2020-02-14 08:13:52 +03:00
parent cf78cd20e3
commit 556ce81106
11 changed files with 42 additions and 16 deletions

View file

@ -1,3 +1 @@
> > > 0
0
5
> > > 5

View file

@ -0,0 +1,10 @@
> 0
1
2
3
4
5
6
7
8
9

View file

@ -1,4 +1,4 @@
fun lazy (f) {
fun makeLazy (f) {
local flag = 0, value = 0;
return fun () {
@ -12,7 +12,7 @@ fun lazy (f) {
}
}
local l = lazy (fun () {write (1); return 800});
local l = makeLazy (fun () {write (1); return 800});
local x = read ();
write (l ());

View file

@ -1,4 +1,4 @@
fun lazy (f) {
fun makeLazy (f) {
local flag = 0, value = 0;
fun () {
@ -12,7 +12,7 @@ fun lazy (f) {
}
}
local l = lazy (fun () {write (1); 800});
local l = makeLazy (fun () {write (1); 800});
local x = read ();
write (l ());

View file

@ -1,4 +1,8 @@
local x;
repeat
local n = read ();
write (n)
until n > 0
x := n
until n > 0;
write (x)

View file

@ -1,3 +1,3 @@
0
0
5
5

5
regression/test104.expr Normal file
View file

@ -0,0 +1,5 @@
local n = read ();
for local i; i := 0, i<10, i := i + 1 do
write (i)
od

1
regression/test104.input Normal file
View file

@ -0,0 +1 @@
5