[Rd] Name spaces and behavior of overloaded functions?
Tue Jan 28 02:29:02 2003
First of all, I haven't followed the discussion about the new/upcoming
name space support in R so I do not know the purposes or requirements
for it, neither its design, and I can only guess. I found the (initial?)
notes by Luke Tierney on the Developers Page. Are there any other
Since it seems that the current implementation (R v1.6.2) of name spaces
is a "trial" version and not really officially announced I though it
would be better to ask my questions on this list:
hist() is internally creating an object of class 'histogram' and calling
plot() on this object, which will (through the S3/UseMethod mechanism)
call plot.histogram(). In pre Rv1.6.x I used to overload the
plot.histogram() with my own backward compatible version, which added
two arguments specifying the width and offset of the bars, making it
easier to have two or more histograms in the same plot.
However, I noticed that since R v1.6.x the hist() -> plot() ->
plot.histogram() sequence is now restricted to hist() -> plot() ->
base::plot.histogram() (not explicitly). Where ever I put my redefined
plot.histogram() function, i.e. before the 'base' package in the
search() path, including .GlobalEnv, it is ignored when calling hist().
Question 1: Is this due to the new name space support?
Question 2: Is this the intendent behavior?
Question 3: If yes of Q2, then should plot.histogram() be considered a
private function of the 'base' package?
Of course it works if I use h <- hist(..., plot=FALSE) and call plot(h,
...) explicitly. However, I am not really interested in a workaround for
this specific problem, but more in how name spaces are going to change R
and if there is a well defined plan/specification at the moment.
Home: 201/445 Royal Parade, 3052 Parkville
Office: Bioinformatics, WEHI, Parkville
+61 (0)412 269 734 (cell), +61 (0)3 9345 2324 (lab),
+1 (508) 464 6644 (global fax)
Time zone: +11h UTC (Sweden +1h UTC, Calif. -8h UTC)