\"R passes promises, not values. The promise is forced when it is first evaluated, not when it is passed.\", see this answer by G. Grothendieck. Also see this question referring
As others pointed out, this might not be the best style of programming in R. But, one simple option is to just get into the habit of forcing everything. If you do this, realize you don't need to actually call force
, just evaluating the symbol will do it. To make it less ugly, you could make it a practice to start functions like this:
myfun<-function(x,y,z){
x;y;z;
## code
}