-
Notifications
You must be signed in to change notification settings - Fork 237
Description
Adding #'@export
to a function such as predict.myclass()
adds S3method(predict, myclass)
to the NAMESPACE file of the package {foo}. However it does not add export(predict.myclass)
.
The result is that foo::predict.myclass
does not exist (only foo:::predict.myclass
).
That can create problem.
For example, if a package {bar} makes no call to foo::fn
but only to the generic stats::predict()
, then the dispatch won't work.
This is because the foo namespace will not be present in the search path (even if package is listed in Imports).
We can go around this problem by e.g. using requireNamespace("foo")
inside bar, but this is not elegant.
Also it is sometimes nice to refer, in internal code at least, directly to the function used so as not to obfuscate where functions come from.
(Another good reason for this is that CMD won't fault if foo is not declared in Imports if stats::predict()
is used).
Perhaps you had a good reason not to create export(predict.myclass)
on top of S3method(predict, myclass)
, but I think that #'@export
suggests to the package developer that the function will be exported while in fact what happens now is that the function is registered but not exported.
If that does not cause problems I don't anticipate, I would thus recommend that #'@export
should generate the export statement in the NAMESPACE file (in addition to the registration).