Java lazy semantics of evaluation

What is the semantics of lazy Java evaluation? Are there triggers stored with assignment stores that add a trigger to the semantic stack of the trigger store if the program contains some syntax that symbolizes a future lazy evaluation? and at runtime, is the program executing a new thread for this purpose, or is execution continuing in the current thread? Also ... I would like to know what possible syntaxes can cause lazy evaluation in Java?

+4
source share
2 answers

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

In Java, if we want the value to be lazily updated, we end its access in the method, where we control the complexity of the evaluation in this method. Some of these constructs are called beans: http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/package-summary.html .

Often you need to create a data structure where all values ​​are received lazily, for example. a list where each item is evaluated lazily, or a map where each value is evaluated lazily. To do this, we can subclass and override the get (), put () methods and other applicable methods from the corresponding Java Collection classes. See the java cache hash cache for an example of this strategy.

+6
source

Java does not have a lazy rating.

Did you mean Scala?

+3
source

Source: https://habr.com/ru/post/1385242/


All Articles