From simon.barthelme at gipsa-lab.fr  Fri Sep  1 12:57:13 2017
From: simon.barthelme at gipsa-lab.fr (=?UTF-8?Q?Simon_Barthelm=c3=a9?=)
Date: Fri, 1 Sep 2017 12:57:13 +0200
Subject: [Rd] side-effect of calling functions via `::`
Message-ID: <59A93D09.8010006@gipsa-lab.fr>

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::lhs(form)
as.character(form)

The first call to as.character returns:
[1] "~" "a" "b"
The second returns:
[1] "a ~ b"

The reason being that formula.tools has:
S3method(as.character,formula)
in its namespace, which quietly supersedes the default one. In my case 
it led to a bug that was rather hard to track down because it looked 
like non-deterministic behaviour.
Shouldn't there at least be a warning about such side effects, the way 
library() tells you about masking?

Best

Simon Barthelme



[Rd] side-effect of calling functions via `::`
=?UTF-8?Q?Simon_Barthelm=c3=a9?=