The is.pos function below results in the variable, out, being set to
TRUE if the first argument to is.pos is positive and to FALSE
otherwise.
It does this without using the return value or using scoping tricks to
reach into the caller. Instead it tricks the promise into
communicating one bit of
On Jan 12, 2013, at 17:02 , Gabor Grothendieck wrote:
The is.pos function below results in the variable, out, being set to
TRUE if the first argument to is.pos is positive and to FALSE
otherwise.
It does this without using the return value or using scoping tricks to
reach into the caller.
In the spirit of this, but AFAIK not due to lazy evaluation, here's
another illustration why it's easy to mistakes when doing inline
assignments:
x - 0
TRUE (x - 1)
[1] TRUE
x
[1] 1
FALSE (x - 2)
[1] FALSE
x
[1] 1
(x - 3) FALSE
[1] FALSE
x
[1] 3
FALSE (x - 4)
[1] FALSE
x
[1] 4