Skip to content
Prev 3391 / 63424 Next

using function names as parameters (PR#469)

hothorn@ci.tuwien.ac.at writes:
This is not a bug. Default arguments are evaluated in the frame of the
called function, so when the date variable is requested and no actual
argument was supplied, R tries to evaluate the default expression, but
that involved the variable "date" again. If you pass an argument, the
default expression is never evaluated and the problem does not arise.

Similarly a definition like

function(x=y, y=x) x + y

is asking for trouble if both x and y are left unspecified on the call.

[This has nothing to do with passing functions as parameters, by the
way]