Cosmetics in stdlib

This commit is contained in:
Dmitry Boulytchev 2020-02-20 12:43:52 +03:00
parent 7fd85f27ef
commit 5933f4c3b1
15 changed files with 105 additions and 79 deletions

View file

@ -1,10 +1,21 @@
-- Lazy.
-- (C) Dmitry Boulytchev, JetBrains Research, St. Petersburg State University, 2020
--
-- Deferred computations.
public fun makeLazy (f) {
local value, set = false;
fun () {
if set
then value
else set := true; value := f (); value
else
local c; -- need this temporary since in value := f () value would
-- create an intermediate managed pointer
set := true;
c := f ();
value := c;
c
fi
}
}