Skip to content
Prev 25659 / 63424 Next

S4 and Namespaces problems {was "error message from lmer"}

On Wed, 18 Jul 2007, Robert Gentleman wrote:

            
I do think base is a special case here, given its privileged position in 
the namespace hierarchy.  I'd take Martin's position as rather that there 
should be only one generic derived by take-over from a function, at least 
for those in base.

I believe that if you are allowed to make a function in base S4-generic 
(and it is not obvious that you should be in many cases), then the derived 
generic should conceptually be in base and thus always be found in place 
of that in base.  Since base is not a normal environment or namespace, 
that is not straightforward to implement but it should be possible by 
(e.g.) C-level hacking and a environment to store such derived generics. 
Primitives are rather different, and we now have a fairly efficient way to 
allow designated primitives to have S4 methods.

I believe the registration model for S3 methods is pretty much the right 
one: methods are set on the first 'foo' on the relevant search path, and 
that does not cause another 'foo' to be created elsewhere that may or may 
not precede the original in the relevant search path (since there are 
multiple search paths once namespaces enter the mix).

The new implied generics model helps here: taking over a function in base 
unaltered (the same as the implied generic) could be a derived generic, 
and any alteration would create a new generic in your package.  That 
protects code in other namespaces from your alterations.
It seems tricky enough to need debate what we want for a while and aim for 
2.6.0.  But we have been discussing it on and off for at least two years.

Brian