It can often be optimal in computing to procrastinate computation to the last possible microsecond. If you are lucky, the computer never needs to do the work.
One common example of procrastination is to use a singleton object instead of static fields. You don’t create the object until you actually need it. Just before every use, you must execute code roughly like this:
if ( singleton == null ) { singleton = new Something(); // further initialisation code ... }
Two other procrastination examples:
The && operator in Java avoids evaluation the right hand operand if the left hand operand is false. This is sometimes called lazy evaluation, short circuit evaluation or McCarthy evaluation. (John McCarthy was the creator of Lisp and is sometimes known as the father of artificial intelligence.)
When a function computes a value and caches the result, to produce it quickly in future without recomputing in case someone asks for the same inputs again, that is also sometimes referred to as lazy evaluation.
This page is posted |
http://mindprod.com/jgloss/lazy.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\lazy.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.149.28.19] |
| |
Feedback |
You are visitor number | |