简体   繁体   中英

Java lazy evaluation semantics

What are the semantics of Java lazy evaluation? Do there exist triggers, stored together with assignment stores that append a trigger to the semantic stack of the trigger store if a program contains some syntax that symbolizes future lazy evaluation? and during execution, does program execution creates a new thread for that exact purpose or execution proceeds in the current thread? Also ... I would like to know what are possible syntaxes that can trigger lazy evaluation in Java?

In Java, lazy evaluation is accomplished often by using object abstractions. In comparison, evaluation of code is passed about liberally in functional languages, making laziness a first-class feature.

In Java, if we want a value to be lazily updated, we wrap it's access in a method where we manage the complexity of evaluation in that method. Some of these constructs are referred to as beans: http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/package-summary.html .

Often one wants to create a data structure where all values are lazily obtained, eg a list where each element is lazily evaluated or a map where each value is lazily evaluated. To do this, we can subclass and override the get(), put(), and other applicable methods from relevant Java Collection classes. See java cache hashmap expire daily for an example of this strategy.

Java doesn't have lazy evaluation.

Did you mean Scala?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM