From ripley at stats.ox.ac.uk  Sun Mar 14 15:27:10 2010
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sun, 14 Mar 2010 14:27:10 +0000 (GMT)
Subject: [Rd] Argument matching for primitives
Message-ID: <alpine.LFD.2.00.1003141008020.28978@gannet.stats.ox.ac.uk>

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



[Rd] Argument matching for primitives
Prof Brian Ripley