Re: [Rd] [patch] giving library() a 'version' argument

From: Ken Williams <Ken.Williams_at_windlogics.com>
Date: Thu, 12 Apr 2012 12:46:33 -0500

> -----Original Message-----
> From: Duncan Murdoch [mailto:murdoch.duncan_at_gmail.com]
> Sent: Thursday, April 12, 2012 12:27 PM
> To: Ken Williams
> Cc: r-devel_at_r-project.org
> Subject: Re: [Rd] [patch] giving library() a 'version' argument
>
> I haven't tested it, but according to the documentation in Writing R
> Extensions, the dependencies are enforced at the time library() is called.

Oh, I hadn't suspected that. I can look into testing that, if it's true then of course that changes this all. I probably won't be able to do that for a few days because I'll be traveling though.

I've never noticed a package failing to load at runtime because its prereq-version dependency wasn't met though.

> [...]
> But a single line at the top of the script would fix this:
>
> stopifnot(packageVersion("foo") == "3.14")

For the most common use case, that would look more like:

    stopifnot(compareVersion(packageVersion("foo"), "3.14") < 0)

which gets less declarative, and I'd argue less clear about exactly what it's trying to enforce.

And I can see myself (& presumably others) getting that comparison operator backwards a lot, having to look it up each time or copy-paste it from other code.

And then that still doesn't add nice error messages, that would be yet more code.

*And*, it doesn't actually behave correctly if the package is already loaded by other code, because it might have been loaded from a different location than the one that would be found in the packageVersion() call. (Or am I maybe wrong about what packageVersion() does in that case? I don't think the docs specify that behavior.)

For prior art on this whole concept, a useful precedent is the 'use()' function in Perl, which accepts a version argument, even though there is also robust version checking at installation/testing time.

>
> Another problem with putting this into library() is that packages aren't
> always loaded by library(): there is require(), and there are implicit
> loads triggered by dependencies of other packages.

That's not really a problem. If someone wants to enforce a runtime dependency, they stick the enforcement line into their code, and it will correctly stop if the criterion is not met.

 -Ken

CONFIDENTIALITY NOTICE: This e-mail message is for the s...{{dropped:7}}



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 12 Apr 2012 - 17:49:02 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Apr 2012 - 18:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive