From murdoch.duncan at gmail.com  Mon Aug 29 14:40:53 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Mon, 29 Aug 2011 08:40:53 -0400
Subject: [Rd] S3 methods in default namespace
In-Reply-To: <CABdHhvEmpotLWD+kSi6SHvhr3Bcoutpx7zJVsRbUYk6DbzZT8Q@mail.gmail.com>
References: <CAOQ5Nyd8bWX7Vh=Y5dXPAPLR3JVpu07XQw1=+sdWnbMebW_QuQ@mail.gmail.com>	<4E592854.9010508@statistik.tu-dortmund.de>	<CABdHhvEDe6CmKW2Jh+7wpX+pU_KL_wXOnTS5xDJM3FBVCRujrw@mail.gmail.com>	<4E5A5DEB.6080701@statistik.tu-dortmund.de>
	<CABdHhvEmpotLWD+kSi6SHvhr3Bcoutpx7zJVsRbUYk6DbzZT8Q@mail.gmail.com>
Message-ID: <4E5B88D5.2030709@gmail.com>

On 29/08/2011 8:20 AM, Hadley Wickham wrote:
> >>  So doesn't that break packages that use S3 but don't have a NAMESPACE?
> >
> >  Maybe, but since the methods are exported as functions they are also found
> >  for method dispatch and imported, if another package imports from the
> >  Namspace. The problem I see is what happens if method dispatch is done on a
> >  package that is not attached but just the Namespace is only loaded.
> >
> >  Anyway, we should really recommend that package authors write NAMESPACE
> >  files in case their packages are not trivial.
> >  Note that there are many CRAN packages that fail under R-devel, some of them
> >  sue to NAMESPACE issues.
>
> I'm not sure I understand the approach of providing a default
> NAMESPACE.  Why not just make it a requirement to pass R CMD check?
> That seems like it would be a safer approach, although it would create
> some work for people who have not yet started using namespaces.

About 1000 packages on CRAN didn't have a NAMESPACE file.  Most of them 
were very simple so our default NAMESPACE is sufficient.  Some of them 
were not so simple, and those ones really need to have a NAMESPACE.

Adding the namespace makes all of the packages more predictable and 
reliable (because it gives a defined search order for functions), but 
there's no point forcing 1000 package authors to do it if it can be done 
automatically.  However, there are at least a few dozen who should have 
done it long ago, and those ones will need to do it to pass checks.

Duncan Murdoch



[Rd] S3 methods in default namespace
Duncan Murdoch