|
|
|
|
|
by wwwwwwwwww
4384 days ago
|
|
honest question: is there any reason to add lazy evaluation to c++ other than to just add more features to the language? lazy evaluation is one of those features where i have absolutely no idea what benefit it actually provides |
|
Good question.
Let's say you have a program like this little python example:
If you use lazy evaluation, each item in the "map" object will only be calculated as needed. So if the first item in the "inputs" list is "42", it will only do a single string-to-integer conversion.If you use greedy evaluation, it will map all strings to integers at once, which might be wasteful.
There are other benefits as well; this is the most obvious.