Lazy object: a promise
a promise of an object, a recipe how to make it
IMAGE image = FractalMap(8);
looks the same as
IMAGE loaded_image = read_new_image_format("image_file.xbmp");
above, but acts completely different!
- constructs and returns a promise rather than the object
promise: a small object holding parameters and a recipe
- the promise is forced only when the object is really needed
- by a copy constructor
- by an assignment operator
- An object is always constructed right in place
- No temporary object(s) are constructed /moved/ destroyed
- Lazy objects (promises) can be used for an asynchronous messaging:
a promise as a future
Examples
More discussion
Next | Table of contents