[R] sub question

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Sun Feb 1 17:23:07 CET 2009


Peter Dalgaard wrote:
> Gabor Grothendieck wrote:
>> On Sat, Jan 31, 2009 at 6:01 PM, Wacek Kusnierczyk
> th some additional boring pedantry wrt. ?gsubfn, which says:
>>>
>>> " If 'replacement' is a formula instead of a function then a one
>>>     line function is created whose body is the right hand side of the
>>>     formula and whose arguments are the left hand side separated by
>>>     '+' signs (or any other valid operator).  The environment of the
>>>     function is the environment of the formula.  If the arguments are
>>>     omitted then the free variables found on the right hand side are
>>>     used in the order encountered.  "
>>>
>>> to my little mind, all of 'paste', 'rep', 'nchar', and 'x' in the
>>> example above are *free variables* on the right of the formula.  you
>>
>> The first three are functions, not variables.
>
> They are still free variables, subject to the same rules of variable
> lookup. Wacek is right: The RHS is scanned recursively for objects of
> mode "name" _except_ when they appear as function names (i.e. if
> subexpression e is mode "call", then forget e[[1]] and look at the
> arguments in as.list(e)[-1]. Not sure if this also happens if e[[1]]
> is not a name, e.g. in f(a)(b), do you get both a and b or just b?)

a follow-up:

foo = function() bar()

is 'foo' in the expression above a variable or a function name (it is
free, anyway)?  (for sure, 'foo' is *not* a function, because here, and
in the above, it is *syntax* that is discussed, and functions are not
syntactic objects)



>
> He is also right that it is pedantry...
>

"Take time to consider.  The smallest point may be the most essential."
Sherlock Holmes, The Adventure of the red Circle

(and i actually quote it from a statistics textbook, written by people
who apparently think care for details matters.  well known
statisticians, for that matter.)

we can agree this is pedantry, i couldn't care less about what you call
it.  the problem is that you (meaning: some of the r folks posting here)
seem to regard care for details as something negative and undesirable,
and discard problems by simply tagging them as 'boring pedantry'.  and
then it's too late, nothing can be done without crashing much old code,
live with it, it's a user bug if your code crashes because obvious
assumptions are often wrong in r.

in this particular case, the issue at stake is users' understanding.  if
you don't care for consistent and correct use of terms (such as 'free
variable'), how can you expect users to understand your manuals, help
pages, and mailing list responses?

vQ




More information about the R-help mailing list