Le 31/05/10 10:41, Barry Rowlingson a écrit :

On Sun, May 30, 2010 at 5:50 PM, Romain Francois
<rom...@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


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to