[Rd] Tricking Promises into Sending Info Via Args into Caller

2013-01-12 Thread Gabor Grothendieck
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

Re: [Rd] Tricking Promises into Sending Info Via Args into Caller

2013-01-12 Thread peter dalgaard
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.

Re: [Rd] Tricking Promises into Sending Info Via Args into Caller

2013-01-12 Thread Henrik Bengtsson
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