[Phylobase-devl] setGeneric vs. setMethod
Peter Cowan
pdc at berkeley.edu
Sun Jun 22 05:17:30 CEST 2008
Hey all,
I'd like to add a new generic 'reorder'. I was looking through the
generics and methods and is appears that for each function we each.
For example the generic "hasNodeLabels" is coded in the following way.
In methods-phylo4.R there exists:
setMethod("hasNodeLabels", "phylo4", function(x) {
length(x at node.label) > 0
})
In the phylo4.R there exists:
setGeneric("hasNodeLabels", function(x) {
standardGeneric("hasNodeLabels")
})
My understanding is that the setGeneric calls the method
standardGeneric() to define the function. However, my understanding
is that these doesn't set the default, it uses the previously set
'hasNodeLabels'. My question is why do we set Generics in this
manner? Couldn't we also do:
setGeneric("hasNodeLabels", useAsDefault = function(x) {
length(x at node.label) > 0
})
(maybe also setting the group parameter, which I don't quite grok)
Thanks
Peter
More information about the Phylobase-devl
mailing list