Skip to content
Prev 50093 / 63424 Next

Proposing a change in the base::sink interface for type argument

It's only an illusion until one actually tries providing a vector.

  > sink('foo', type=c('s','m'))
  Error in match.arg(type) : 'arg' must be of length 1

The additional benefit of match.arg() which you may have not appreciated
is that it allows the user to abbreviate. That is,
  > sink('foo', type='o')
is valid usage. The essential concept of match.arg() is that it tries to
match whatever the user supplied with one, and only one, of the values
provided in the argument's default value, and that is the value used in
the rest of the function.

For example:
aa
bb
Error in match.arg(arg) : 'arg' should be one of "aa", "bb", "cc"
aa 




Being "non-intuitive" or puzzling to people coming from other languages is
not a sufficient reason for a change. Obviously, different languages have
different features, otherwise, why bother to have different languages?
 
And yes, match.arg() is widely used in R. I find it quite useful in my own
programming.