Skip to content
Prev 17058 / 398502 Next

Scope?

Thanks to Doug Bates and Ray Brownrigg, who both referred to 
'lazy evaluation' as an argument for not allowing my construct.
However, I'm not completely convinced. As I understand it, when
a variable pops up (on the 'right hand side') in an expression in a 
function,  R  looks for it in the following order:

1. Local (to the function) variable?
2. Formal argument?
3. In the defining environment?

The potential problem occurs when the answer to  1.  is 'No' and the
answer to  2.  is 'Yes', and no value was given to  x  in the call.
Then the current procedure obviously is to look at the default, and go
thru steps  1.-3.  again to find it. (Am I correct?) Then  x=x  is found,
and the 'recursive default ...' is detected. But I mean that when looking 
for the default among the formal arguments, *the current one must be 
excluded*, and the search continue to  3., if necessary.

What have I overlooked?

G?ran
On 9 Feb 2002, Douglas Bates wrote: