短路求值
Short-circuit evaluation
最早是在php中接触到的这种求值,后来在学习Lisp中又一次接触到了,于是想写一篇文章记录一下,并分享一下,这个被我忽略的可能可以说是细节的点吧
什么是短路求值(Short-circuit evaluation)
Short-circuit evaluation, minimal evaluation, or McCarthy evaluation (after John McCarthy) is the semantics of some Boolean operators in some programming languages in which the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression: when the first argument of the AND function evaluates to false, the overall value must be false; and when the first argument of the OR function
evaluates to true, the overall value must be tru