mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-15 03:08:46 +00:00
Fixed bug with mutable closures in interpret (not really --- up to closure recursion)
This commit is contained in:
parent
1d28f4af6b
commit
dad4c35a80
5 changed files with 31 additions and 7 deletions
19
regression/test068.expr
Normal file
19
regression/test068.expr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
fun lazy (f) {
|
||||
local flag = 0, value = 0;
|
||||
|
||||
return fun () {
|
||||
if flag
|
||||
then return value
|
||||
else
|
||||
value := f ();
|
||||
flag := 1;
|
||||
return value
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
local l = lazy (fun () {write (1); return 800});
|
||||
local x = read ();
|
||||
|
||||
write (l ());
|
||||
write (l ())
|
||||
Loading…
Add table
Add a link
Reference in a new issue