On Tue, Feb 10, 2009 at 8:31 AM, Duncan Murdoch <murdoch@stats.uwo.ca>wrote:

> Stavros Macrakis wrote:
>
>> It is a bad idea to set data.frame <- xxx since R has a single
>> namespace for functions and variables.
>>
>>
> That's not quite accurate.  R mixes functions and variables in namespaces,
> but it has lots of namespaces, and it usually doesn't cause much trouble to
> have a variable named data.frame in one, and a function named data.frame in
> another.  The evaluator recognizes the context of usage and will get the
> function for a function call. If you retrieve data.frame without doing a
> function call, you'll get whichever one it finds first, which is typically
> the one in the global environment, as below.
>

Interesting.  I was not aware of this rule.

Can you point me to chapter and verse in the language definition (
http://cran.r-project.org/doc/manuals/R-lang.html)?  I couldn't find it, but
I probably looked in the wrong place.

| Sometimes this causes trouble (e.g. if you passed data.frame to apply or
do.call), but usually not, ...

Indeed!  It is quite surprising that functions are defined using ordinary
assignment, but function lookup is different from normal variable
evaluation, e.g. that after c<-4, c(10) is different from (c)(10).  Was this
inspired by some other language? I don't think it's done this way in any
other language I can think of....

          -s

	[[alternative HTML version deleted]]

