Hi,

Please consider the following trivial example.
In the sample code I first define a class MVCa using composition. This class contains a slot of type list.
Next I define an inheritance relation using the function setIs -> MVCa "is a" list.
Then I define a function printlength which prints the list-length which is defined for the type "list".
If I call this function assigning to their argument an object of class MVCa I would expect that the function _coerce_ defined in setIs will be called.
It seems that this never happens using:
R : Copyright 2004, The R Foundation for Statistical Computing
Version 2.0.0 Patched (2004-10-04), ISBN 3-900051-07-0




setClass(
"MVCa"
,representation(list="list"
,content="character")
,prototype(content="numeric")
)
setIs("MVCa","list",coerce=function(obj)[EMAIL PROTECTED],replace=function(obj,value)[EMAIL PROTECTED]<-value})


setGeneric("printlength",function(object,...) standardGeneric("printlength"))
setMethod("printlength"
,signature(object="list")
,def=function(object)
{
print(length(object))
}
)



xx<-as.list(1:4) names(xx)<-letters[1:4] mvca<-new("MVCa") [EMAIL PROTECTED]<-xx

printlength(mvca)


Any suggestions?

/E

--
Dipl. bio-chem. Witold Eryk Wolski MPI-Moleculare Genetic
Ihnestrasse 63-73 14195 Berlin _
tel: 0049-30-83875219 __("< 'v'
http://www.molgen.mpg.de/~wolski \__/ / \
mail: [EMAIL PROTECTED] ^^ w w
[EMAIL PROTECTED]


______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to