I think Brian's question --- what are you trying to do? -- should be the first order of business.
Someone can make R do just about anything, but it is better to do a few things very well than lots of things in a muddled way.
So. What is the advantage of using assignment as a generic? I'm open-minded about there being such an advantage, but I don't see any right off.
Patrick Burns
Burns Statistics [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User")
Thomas Koenig wrote:
Am Samstag, 26. Juli 2003 11:38 schrieb Peter Dalgaard BSA:
Peter Dalgaard BSA <[EMAIL PROTECTED]> writes:
Prof Brian Ripley <[EMAIL PROTECTED]> writes:
What are you trying to do with this? Assignment (<-) is not a
function,
But what the difference between <- and e.g. the function length or "[<-"? As I understood in "methods" everything has a class. And R says me with is(...) (hope that the results are correct):
< is(get("<-"))
[1] "function" "OptionalFunction" "PossibleMethod"
< is(get("length"))
[1] "function" "OptionalFunction" "PossibleMethod"
is(get("[<-"))[1] "function" "OptionalFunction" "PossibleMethod"
## test for the correct result of get(...) ?[1] "numeric" "vector"
x <- 10
is(get("x"))
## and[1] "<-"
setGeneric("<-")
Warning message:
"<-" is a primitive function; its generic definition is built in and automatically included. in: setGeneric("<-")
and the language grammar does not convert a <- b into "<-"(a,Eh? Are you sure about that???
b) (as it would with the binary operator functions). You could call it
that way, and then it will probably work.
quote("<-"(a,b))a <- b
Adding on to this, I think the point is that assignment bypasses the usual *evaluation* rules, even though it is syntactically a binop.
I think it basically has to be so: For one thing, it is kind of
difficult to check for a signature match without evaluating the
arguments and the left hand side of an assignment will not in general
exist at that point.
In the methods is the class "missing". Could that help? for one thing : signature=c("missing","A") (only allowed for <- ?) for both things: signature=c("A","B") for nothing ;-) : signature=c("missing","missing")
Thanks and Best Regards
Thomas K�nig
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
