This seems to do the trick, but it does not feel right:
.onLoad <- function( libname, pkgname ){ utils <- asNamespace( "utils" ) unlockBinding( ".DollarNames", utils ) assignInNamespace( ".DollarNames", .DollarNames, utils ) lockBinding( ".DollarNames", utils ) } Any better idea ? Romain Le 29/05/10 13:21, Romain Francois a écrit :
Hello, I'm trying to make .DollarNames generic and implement a method for it in a package. .DollarNames is the function that is now called to get completion possibilities. My R code looks like this: setGeneric( ".DollarNames" ) setClass("track", representation(x="numeric", y="numeric")) ## A class extending the previous, adding one more slot setClass("trackCurve", representation(smooth = "numeric"), contains = "track") setMethod( ".DollarNames", signature( x = "track", pattern = "character" ), function(x, pattern){ grep( pattern, c("foo", "bar"), value = TRUE ) } ) and the NAMESPACE : import( utils ) exportMethods( .DollarNames ) exportClasses( track, trackCurve ) When I load the package, I can call .DollarNames explicitely : > require( foo ) > x <- new( "trackCurve", x = 1:10, y = 1:10, smooth = 1:10 ) > .DollarNames( x, "f" ) [1] "foo" but completion does not work : > x$f<TAB> x$ What do I miss ? I've uploaded foo here : http://addictedtor.free.fr/misc/rcpp/foo_1.0.tar.gz Romain
-- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/9CQ66r : RMetrics 2010 |- http://bit.ly/cork4b : highlight 0.1-8 `- http://bit.ly/bklUXt : RcppArmadillo 0.2.1 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel