Tim Taylor
2024-Oct-17 12:42 UTC
[Rd] Consider getNamespaceVersion() returning a numeric_version
I mean the `numeric_version` object not a numeric (double/int). Basically to protect me from myself I'd prefer not to have to remember to wrap `getNamespaceVersion()` with `as.package_version()`. I suspect a grep of CRAN may highlight others who are erroneously comparing character objects rather than a comparison between a `numeric_version` object and a character. Tim On 17/10/2024 13:22, Dirk Eddelbuettel wrote:> On 17 October 2024 at 12:38, Tim Taylor wrote: > | Would R-Core be receptive to having getNamespaceVersion() return a > | numeric_version object instead of a named character? > > Is this good enough? What's your actual issue a 'numeric' would address? > > > as.package_version(getNamespaceVersion("base")) < "4.5.0" > [1] TRUE > > > > as.package_version(getNamespaceVersion("Rcpp")) > "1.0.11" > [1] TRUE > > as.package_version(getNamespaceVersion("Rcpp")) > "1.0.14" > [1] FALSE > > > > Dirk >
Dirk Eddelbuettel
2024-Oct-17 13:00 UTC
[Rd] Consider getNamespaceVersion() returning a numeric_version
On 17 October 2024 at 13:42, Tim Taylor wrote: | I mean the `numeric_version` object not a numeric (double/int). | Basically to protect me from myself I'd prefer not to have to remember | to wrap `getNamespaceVersion()` with `as.package_version()`. That would be a breaking change. I suspect you would need to supply stronger motivation. Note that these days you can add arbitrary fields to DESCRIPTION so you already can add a new field that you can the require to be a value from an integer sequence (or a numeric if you prefer). | I suspect a grep of CRAN may highlight others who are erroneously | comparing character objects rather than a comparison between a | `numeric_version` object and a character. Sure but still a user-level bug though. Usually those get fixed them on that side. (And to be clear, I have nothing against your proposal per se and like it in the abstract. I am just trying to help think through what it may entail.) Dirk -- dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Prof Brian Ripley
2024-Oct-17 14:53 UTC
[Rd] Consider getNamespaceVersion() returning a numeric_version
On 17/10/2024 13:42, Tim Taylor wrote:> I mean the `numeric_version` object not a numeric (double/int). > Basically to protect me from myself I'd prefer not to have to remember > to wrap `getNamespaceVersion()` with `as.package_version()`. > > I suspect a grep of CRAN may highlight others who are erroneously > comparing character objects rather than a comparison between a > `numeric_version` object and a character.Perhaps you could do that rather than speculating? Similarly, try out over CRAN the effect of getNamespaceVersion changing its return type. It seems to be used in less than 40 CRAN packages, many boilerplate code from a single author and most use the version as a printable character string. A few are clearly wrong: E.g. if(getNamespaceVersion("reticulate") >= "1.36.0") will be false it that package ever reaches "1.100.0". This is what compareVersion() is for ....> On 17/10/2024 13:22, Dirk Eddelbuettel wrote: >> On 17 October 2024 at 12:38, Tim Taylor wrote: >> | Would R-Core be receptive to having getNamespaceVersion() return a >> | numeric_version object instead of a named character? >> >> Is this good enough? What's your actual issue a 'numeric' would address? >> >> ??? > as.package_version(getNamespaceVersion("base")) < "4.5.0" >> ??? [1] TRUE >> ??? > >> ??? > as.package_version(getNamespaceVersion("Rcpp")) > "1.0.11" >> ??? [1] TRUE >> ??? > as.package_version(getNamespaceVersion("Rcpp")) > "1.0.14" >> ??? [1] FALSEThere are differences, e.g. > (z <- getNamespaceVersion("MASS")) version "7.3-61" > (zz <- as.package_version(z)) [1] ?7.3.61? > as.character(zz) [1] "7.3.61" and some uses need the first. That makes changing the return value too disruptive. If the issue is only comparison, getNamespaceVersion's return value could be given a class and an Ops group method, but the existence of compareVersion() makes that less compelling. -- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford
Seemingly Similar Threads
- Consider getNamespaceVersion() returning a numeric_version
- Consider getNamespaceVersion() returning a numeric_version
- Consider getNamespaceVersion() returning a numeric_version
- max on numeric_version with long components
- max on numeric_version with long components