From hb at stat.berkeley.edu  Mon May 31 11:17:31 2010
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Mon, 31 May 2010 11:17:31 +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: <AANLkTikaVEXctDWlzGDEj2BINC5nhG-zMyI4VXs0jn7e@mail.gmail.com>

On Mon, May 31, 2010 at 10:41 AM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> 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)", for example, but having a minimum.version
> argument makes more sense. Shouldn't be that difficult, you've written
> most of it already!

I agree that this would be a useful extension to have.  Exact setup of
arguments can be discussed.  I agree that only having "foo (>= 2.1)"
is not good (though probably the most flexible one).  It might be that
one want to specify a range of versions to load.

Also, consider the case where are three libraries on the .libPaths()
each having a different version of foo installed (this can happen in
shared setups), e.g.

libA/ containing foo v2.0
libB/ containing foo v2.1
libC/ containing foo v2.2

and .libPaths() contains libA, libB and libC in that order.

What should happen with:

(a) require("foo") - should it load v2.0, v2.1 or v2.2?  Today the
first one on the search path, i.e. v2.0.
(b) require("foo (>= 2.1)") - should it throw an error saying it found
v2.0 but it is not sufficient, or should it skip v2.0 and load v2.1 or
v2.2?
(c) require("foo (<= 2.1)") - should it load v2.0 or v2.1?

If require() is smart and skips insufficient versions, that is, does
not just load the first available one, then one also have to worry
about consistency to other functions such as packageDescription().

/Henrik

>
> ?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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] require( "foo (>= 2.1)" )
Henrik Bengtsson