cbind is not generic as claimed, omits labels where S has them
(PR#239)
Prof Brian D Ripley
ripley@stats.ox.ac.uk
Fri, 6 Aug 1999 22:49:07 +0100 (GMT Daylight Time)
On Sat, 7 Aug 1999, Ross Ihaka wrote:
> Ok, I have made some changes to cbind/rbind which will support dispatch
> to other methods. As part of this I have changed things so that the
> values passed on are packaged up as (evaluated) promises so that any
> closure they invoke will be able to use substitute to get text values
Sorry, are you using `closure' to mean `method' in S (and I thought R)
terminology? (I thought a function closure involved the environment....)
> to use as labels. What I need is a clear idea of the rules for doing
> the dispatch. The picture I have at present is:
>
> dispatch.class <- "default"
> for (arg in arg.list) {
> if (arg is an object) {
> arg.class <- class(arg)[1]
> if (there is a method for arg.class) {
> if (dispatch.class == "default")
> class <- arg.class
> else if (args.class != dispatch.class)
> drop through to dispatch
> }
> }
> }
> dispatch:
> if (dispatch.class != "default")
> dispatch to appropriate closure
> else
> carry out default actions
>
> This also looks like it sufficiently generic that it could be packaged
> as a useful function along the lines of "DespatchOrEval" -- perhaps
> MultiDespatchOrEval.
>
> Does this sound right?
`right', huh? That's hard. I had been thinking about multiple classes,
which bedevil all this (and JMC got rid of for that reason, I guess). I
think your rules says choose the class of the leading argument whose first
class has a method, and I think that is wrong. Suppose my two args both
have class c("mts", "ts") and there is no cbind.mts. Then you will dispatch
the default, even though the normal rules for dispatching on the first arg
would dispatch cbind.ts.
I suspect we need to try more than the first method, but have no clear
picture of what is right. I would dispatch on the first arg that had a
usable method.
Brian
--
Brian D. Ripley, ripley@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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._