From Wikipedia:
Lazy evaluation is:
In programming language theory, lazy evaluation or call-by-need is an evaluation strategy which delays the evaluation of an expression until its value is needed
Short-circuit evaluation, minimal evaluation, or McCarthy evaluation denotes the semantics of some Boolean operators in some programming languages in which the second argument is only executed or evaluated if the first argument does not suffice to determine the value of the expression
So what's the difference between them for example when I have:
if(false && true && true) {
//boo
}
As far as I know, compiler doesn't execute expressions after false
because I have &&
so the whole expression will be false
finally. (right?)
So is that behavior called Lazy evaluation or Short-circuit evaluation?
executing
is the correct word, isn't it? – Afshin Mehrabani