Hi all,
I don't understand why this does not what I expect :
## code start here ##############
setClass("num",representation(x="numeric"))
num<-function(x) new("num",x=x)
add<-function(e1,e2) {
cat("Computing
",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n")
e1@x+e2@x
}
setMethod("+","num",function(e1,e2) {
cat("Computing
",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n")
e1@x+e2@x
})
a<-num(3.2)
b<-num(-1.4)
add(a,b)
a+b
## code ends here ##############
a+b does not work : I would like that add(a,b) and a+b give the exact same
result
I've seen a post on R-devel, but the answer seemed not to apply here.
I've tried to use deparse(substitute(e1,sys.frame(-1))) and
deparse(substitute(e1,sys.frame(-2))) (as it was advised by GG in january
2006). But it did not work.
Therefore, i'm looking for 1) an explanation for this phenomenon (link to a
doc, anything) and/or 2) a way to do what i want, if it is possible.
Thanks a lot
[[alternative HTML version deleted]]