public interface Lazy<T>
Promise
, but
Future
also implements Lazy
.
Primitive operations (such as arithmetic) require non-lazy (or "eager") values;
in Kawa these are automatically evaluated ("forced")
using Promise.force(java.lang.Object)
or equivalent.
In Kawa all objects are considered eager (non-lazy) unless the
object's class implements Lazy
, though note that an eager value
may contain lazy components (for example an eager vector of lazy values).
Note that the compiler assumes that Promise.force(java.lang.Object)
is a no-op and
does not need to be emitted unless the type of the value implements
Lazy
, or the class is Object
.
(See LazyType.maybeLazy(gnu.bytecode.Type)
.)
Modifier and Type | Method and Description |
---|---|
T |
getValue()
Return the actual value.
|
T getValue()
getValue()
may return this
,
if this object isn't actually lazy.
It may also return another lazy value.
Normally you should use Promise.force{val}
to extra a non-lazy (eager) value.