%implementing call by need in Oz: local Sqr in proc {Sqr A} local T B in T = {ByNeed fun {$} B = {A} end} {Wait T} B := @B * @B end end local C = {NewCell 0} in C := 25 {Sqr fun {$} C end} {Browse @C} end end % showing that the argument is not evaluated if not used: local Sqr in proc {Sqr A} local T B in T = {ByNeed fun {$} B = {A} end} {Browse "argument not used"} end end local AssignC = fun {$ C} C := @C + 25 C end C = {NewCell 0} in {Sqr fun {$} {AssignC C} end} {Browse @C} end end % showing that the argument is evaluated only once even if used % multiple times: local Sqr in proc {Sqr A} local T B in T = {ByNeed fun {$} B = {A} end} {Wait T} {Wait T} {Wait T} B := @B * @B end end local AssignC = fun {$ C} C := @C + 25 C end C = {NewCell 0} in {Sqr fun {$} {AssignC C} end} {Browse @C} end end