From murdoch at stats.uwo.ca  Wed Nov  9 21:03:26 2005
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 09 Nov 2005 15:03:26 -0500
Subject: [Rd] Packages that require other packages - How?
In-Reply-To: <CAA6F9CF-F9EB-460D-9560-E1805FE0EFBF@stat.berkeley.edu>
References: <1131555027.32250.37.camel@gsimpson.geog.ucl.ac.uk>
	<43723072.6040307@stats.uwo.ca>
	<CAA6F9CF-F9EB-460D-9560-E1805FE0EFBF@stat.berkeley.edu>
Message-ID: <4372560E.2050604@stats.uwo.ca>

On 11/9/2005 1:31 PM, Kasper Daniel Hansen wrote:
> On Nov 9, 2005, at 9:22 AM, Duncan Murdoch wrote:
> 
>> On 11/9/2005 11:50 AM, Gavin Simpson wrote:
>>> Dear list,
>>>
>>> The help page for library/require contains the following paragraph in
>>> the section "Packages that require other packages":
>>>
>>>      The source code for a package that requires one or more other
>>>      packages should have a call to 'require', preferably near the
>>>      beginning of the source, and of course before any code that uses
>>>      functions, classes or methods from the other package.
>>>
>>> Now, I'm being very dense today, but I don't know where to put such a
>>> call to require.
>>>
>>> My package has added methods for a generic function supplied by  
>>> another
>>> package. I have listed this package in the Depends field in my
>>> DESCRIPTION.
>>>
>>> What do I need to do to have the package that my package depends  
>>> on be
>>> attached when I call library or require to attach my package?
>>>
>>> Apologies for being dense...
>>
>> You can either put a call to require() in the function that needs it
>> (which would be the best solution if that function is relatively  
>> rarely
>> used), or in the startup code (in .First.lib, .onLoad, or .onAttach:
>> see the manual for the differences) if you make extensive use of the
>> other package.
> 
> But isn't it true that the introduction of the DEPENDS field in the  
> description file, largely makes calls to require obsolete? My  
> impression is that require calls are mostly used to make examples  
> execute if the depend on a suggested package. I may be wrong of course.

No, you're right, I was wrong.

Duncan Murdoch



[Rd] Packages that require other packages - How?
Duncan Murdoch