[Rd] Argument matching for primitives

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Mar 14 15:27:10 CET 2010


Recent changes to R-devel has altered the way arguments are matched in 
most primitives to be identical to the argument matching in 
interpreted functions.  So if argument names are supplied they are 
checked, surplus arguments are errors, and it is possible to use 
(perverse) constructions like substitute(e=list(x=1), y ~ x).

There are a few deliberate exceptions:  functions like

call switch .C .Call

need to always match the first argument avoiding partial matching to 
named arguments in '...', and do use positional matching.  And the 
perverse

x <- 1
x <- `length<-`(value=3, x=x)

is now an error: two-argument replacement functions still need 'value' 
supplied as the second argument but the names are checked.

This has caught long-term errors in several packages, e.g. people 
writing proc.time(<expression>) where system.time() was more 
plausible, misusing nargs() (if you want the number of args in ..., 
use length(list(...)), not nargs(...)), using on.exit(par=opar) not 
on.exit(par(opar)), and so on.

Specifically CRAN packages NMF, RobAStBase, TTR, aroma.light, catspec, 
gvlma, mvbutils, orloca, orloca.es, sm and staRt now fail in R-devel 
(and also some that use them).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list