Skip to content
Prev 48883 / 63424 Next

dubious behaviour of match.arg() with nested functions.

More specifically, you're satisifying and not satisfying

    if (identical(arg, choices))
        return(arg[1L])

within the definition of match.args for x, and global, respectively.

arg is what is passed to the function (outer default) but choices isn't
specified so match.args uses nonstandard evaluation to populate it with the
default value *in the the call frame from which match.args was called*,
i.e. the *inner* default value. (See the details section of ?match.args)

The take away here is that match.args without explicitly setting choices is
dangerous except in top level functions, and that more generally
non-standard evaluation is dangerous and should be used sparingly and with
care.

~G
On Mon, Aug 25, 2014 at 8:22 AM, Hadley Wickham <h.wickham at gmail.com> wrote: