Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread S Ellison
> -Original Message- > From: R-devel [mailto:r-devel-boun...@r-project.org] On Behalf Of Martin > Maechler > ... > > Lionel Henry > > A package should probably never register a S3 method unless it owns > > either the generic or the class. > > I agree... (and typically it do

Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread Lionel Henry
> in some sense you'd want it to be local to the package code when the > package is not attached, but that's not supported in R as it is now. Lexically scoped methods work well (e.g. all methods in the base package) but they are discouraged by a WARNING in R CMD check: ``` Found the following app

Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread Simon Urbanek
Really, we have three levels of behavior related to dispatch: not loaded, loaded and attached. The loaded state is the most fragile - it does change some behavior (like the one below) but not others (when the package defines a new version of a generic). So it is true that the dispatch is the mos

Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread Simon Urbanek
Really, we have three levels of behavior related to dispatch: not loaded, loaded and attached. The loaded state is the most fragile - it does change some behavior (like the one below) but not others (when the package defines a new version of a generic). So it is true that the dispatch is the mos

Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread Martin Maechler
> Lionel Henry > on Fri, 1 Sep 2017 13:47:07 +0200 writes: > A package should probably never register a S3 method unless it owns > either the generic or the class. I agree... (and typically it does "own" the class) > Here `formula.tools` owns neither. i.e., it neither d

Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread Martin Maechler
> Simon Barthelmé > on Fri, 1 Sep 2017 12:57:13 +0200 writes: > Dear list > I'm not sure whether this is a bug or an unavoidable consequence of the > way packages are loaded, but there can be surprising side effects of > calling a function via package::function. Here

Re: [Rd] side-effect of calling functions via `::`

2017-09-01 Thread Lionel Henry
A package should probably never register a S3 method unless it owns either the generic or the class. Here `formula.tools` owns neither. Instead of registering the method, it should export it like a regular function. This way S3 dispatch is based on lexical scoping rather than session-wide side effe

[Rd] side-effect of calling functions via `::`

2017-09-01 Thread Simon Barthelmé
Dear list I'm not sure whether this is a bug or an unavoidable consequence of the way packages are loaded, but there can be surprising side effects of calling a function via package::function. Here's an example using the formula.tools package: form <- a ~ b as.character(form) formula.tools::