From romain at r-enthusiasts.com  Mon May 31 11:17:15 2010
From: romain at r-enthusiasts.com (Romain Francois)
Date: Mon, 31 May 2010 11:17:15 +0200
Subject: [Rd] require( "foo (>= 2.1)" )
In-Reply-To: <AANLkTikymtVD6zL7re88rCO8JMA3xDZv8e8AkqrrvZJi@mail.gmail.com>
References: <4BFFFCA2.60201@r-enthusiasts.com>
	<4C025EBC.804@embl.de>	<4C029770.2070707@r-enthusiasts.com>
	<AANLkTikymtVD6zL7re88rCO8JMA3xDZv8e8AkqrrvZJi@mail.gmail.com>
Message-ID: <4C037E9B.1050501@r-enthusiasts.com>

Le 31/05/10 10:41, Barry Rowlingson a ?crit :
>
> On Sun, May 30, 2010 at 5:50 PM, Romain Francois
> <romain at r-enthusiasts.com>  wrote:
>> Hi,
>>
>> Sure. I could and I would provide a patch. Since this is more of a "nice to
>> have", I wanted to first find out whether others would find it useful, and
>> also if such a patch would have chances to get accepted by one of R-core
>> members.
>>
>> Sometimes patches I or others provide upfront are not accepted. I'm not
>> complaining about it, it is always an opportunity to learn something ...
 >
>   For starters you could write a function called "requireVersion" that
> does what you want. That would help you (since you say you often find
> yourself using this paradigm) and also it would help anyone else who
> does this. And since it wouldn't be a patch to R it wouldn't need
> R-gods to approve it. It would also make you think about how you'd
> parameterise the call - I wouldn't want to build something that had to
> parse "foo (>=2.1)"

The code already exists, to process DESCRIPTION files with:

Depends: foo (>= 2.1)

but I think I also prefer using another argument anyway. Then there is 
also : what do you do if a lower version is found: warning, error, 
something that is parameterized y another argument, ...

> for example, but having a minimum.version
> argument makes more sense. Shouldn't be that difficult, you've written
> most of it already!
>
>   It might then get included in one of the packages of miscellany on
> CRAN, and then maybe become core R functionality (if you sacrifice the
> required animal to the R-gods, of course).
>
> Barry

The problem with another function on top of require or library is that 
it either has to copy a lot of code from library or first call library 
and then find out if the loaded version is high enough. I think it is 
better that the package is not loaded at all if the version is not good 
enough (it might load the packages it depends on for nothing, etc ...) 
which is why I think a patch to library makes more sense.



But, library or require currently don't have a ... sink so code like :

require( "foo", min.version = "2.1" )

would only work in, say R 2.12.0.


Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/99bz5D : highlight 0.1-9
|- http://bit.ly/9CQ66r : RMetrics 2010
`- http://bit.ly/bklUXt : RcppArmadillo 0.2.1





[Rd] require( "foo (>= 2.1)" )
Romain Francois