Are there technical reasons that package names cannot be snake case? This seems to be enforced by `.standard_regexps()$valid_package_name` which currently returns "[[:alpha:]][[:alnum:].]*[[:alnum:]]" Is there any technical reason this couldn't be altered to accept `_` as well, e.g. "[[:alpha:]][[:alnum:]._]*[[:alnum:]]" I realize that historically `_` has not always been valid in variable names, but this has now been acceptable for 15+ years (since R 1.9.0 I believe). Might we also allow underscores for package names? Jim
On 08/08/2019 10:31 a.m., Jim Hester wrote:> Are there technical reasons that package names cannot be snake case? > This seems to be enforced by `.standard_regexps()$valid_package_name` > which currently returns > > "[[:alpha:]][[:alnum:].]*[[:alnum:]]" > > Is there any technical reason this couldn't be altered to accept `_` > as well, e.g. > > "[[:alpha:]][[:alnum:]._]*[[:alnum:]]" > > I realize that historically `_` has not always been valid in variable > names, but this has now been acceptable for 15+ years (since R 1.9.0 I > believe). Might we also allow underscores for package names?The tarball names separate the package name from the version number using an underscore. There is code that is written to assume there is at most one underscore, e.g. .check_package_CRAN_incoming in src/library/tools/R/QC.r. That code could be changed, but so could the proposed package name... Duncan Murdoch
To be clear, I'd be happy to contribute code to make this work, with the changes mentioned by Duncan and elsewhere in the codebase, if someone on R-core was interested in reviewing it. Jim On Thu, Aug 8, 2019 at 11:05 AM Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> > On 08/08/2019 10:31 a.m., Jim Hester wrote: > > Are there technical reasons that package names cannot be snake case? > > This seems to be enforced by `.standard_regexps()$valid_package_name` > > which currently returns > > > > "[[:alpha:]][[:alnum:].]*[[:alnum:]]" > > > > Is there any technical reason this couldn't be altered to accept `_` > > as well, e.g. > > > > "[[:alpha:]][[:alnum:]._]*[[:alnum:]]" > > > > I realize that historically `_` has not always been valid in variable > > names, but this has now been acceptable for 15+ years (since R 1.9.0 I > > believe). Might we also allow underscores for package names? > > The tarball names separate the package name from the version number > using an underscore. There is code that is written to assume there is > at most one underscore, e.g. .check_package_CRAN_incoming in > src/library/tools/R/QC.r. > > That code could be changed, but so could the proposed package name... > > Duncan Murdoch
Please, no. I'd also like to disallow uppercase letters in package names. For instance, the cuteness of using a capital "R" in package names is outweighed by the annoyance of trying to remember which packages use an upper-case letter. On Thu, Aug 8, 2019 at 9:32 AM Jim Hester <james.f.hester at gmail.com> wrote:> Are there technical reasons that package names cannot be snake case? > This seems to be enforced by `.standard_regexps()$valid_package_name` > which currently returns > > "[[:alpha:]][[:alnum:].]*[[:alnum:]]" > > Is there any technical reason this couldn't be altered to accept `_` > as well, e.g. > > "[[:alpha:]][[:alnum:]._]*[[:alnum:]]" > > I realize that historically `_` has not always been valid in variable > names, but this has now been acceptable for 15+ years (since R 1.9.0 I > believe). Might we also allow underscores for package names? > > Jim > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Kevin Wright [[alternative HTML version deleted]]
Hi Jim, While its true that it wouldn't be *particularly *hard^^ to adapt the base code to change this, there is certainly a non-zero amount of user/package code that relies on the well-defined package tarball naming scheme as well. I know because I've written some myself in switchr/GRAN* but I seriously doubt I'm the only one. I would imagine there's also quite a bit of more if you include DEVOPSy-style build/administration scripts and not just user R code. To me, the benefit of this change seems a pretty minor "nice-to-have" when weighed against breaking even a moderate amount of existing code. ^^ making sure we found every place the tarball naming scheme/package name constraints are implicitly assumed in the R sources might well be less trivial than we think, though once found I agree the changes would likely be *relatively* straightforward. For example, I happen to know that in addition to the places Duncan pointed out, tools::update_PACKAGES relies heavily on code that extracts the name and version of a package from something that "looks like a package tarball" as an optimization mechanism, so that would need to be reworked. It seems likely (almost certain?) that write_PACKAGES also relies on matching the tarball-name patter when determining which packages are present, though I remember less details there because I didn't write most of it. Best, ~G On Fri, Aug 9, 2019 at 9:40 AM Kevin Wright <kw.stat at gmail.com> wrote:> Please, no. I'd also like to disallow uppercase letters in package names. > For instance, the cuteness of using a capital "R" in package names is > outweighed by the annoyance of trying to remember which packages use an > upper-case letter. > > On Thu, Aug 8, 2019 at 9:32 AM Jim Hester <james.f.hester at gmail.com> > wrote: > > > Are there technical reasons that package names cannot be snake case? > > This seems to be enforced by `.standard_regexps()$valid_package_name` > > which currently returns > > > > "[[:alpha:]][[:alnum:].]*[[:alnum:]]" > > > > Is there any technical reason this couldn't be altered to accept `_` > > as well, e.g. > > > > "[[:alpha:]][[:alnum:]._]*[[:alnum:]]" > > > > I realize that historically `_` has not always been valid in variable > > names, but this has now been acceptable for 15+ years (since R 1.9.0 I > > believe). Might we also allow underscores for package names? > > > > Jim > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > -- > Kevin Wright > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]
Won't it be better to have a convention that allows lowercase, dash, underscore and dot as only valid characters for new package names and keep the ancient format validation scheme for older package names? This could be implemented by a single function, taking a strictNaming_b_1 parameter which defaults to true. Easy to use, and compliance results will vary according to the parameter value, allowing strict compliance for new package names and lazy compliance for older ones. Doing so allows to enforce a new package name convention while also insuring continuity of compliance for already existing package names. Fabien GELINEAU alias Neonira Le ven. 9 ao?t 2019 ? 18:40, Kevin Wright <kw.stat at gmail.com> a ?crit :> Please, no. I'd also like to disallow uppercase letters in package names. > For instance, the cuteness of using a capital "R" in package names is > outweighed by the annoyance of trying to remember which packages use an > upper-case letter. > > On Thu, Aug 8, 2019 at 9:32 AM Jim Hester <james.f.hester at gmail.com> > wrote: > > > Are there technical reasons that package names cannot be snake case? > > This seems to be enforced by `.standard_regexps()$valid_package_name` > > which currently returns > > > > "[[:alpha:]][[:alnum:].]*[[:alnum:]]" > > > > Is there any technical reason this couldn't be altered to accept `_` > > as well, e.g. > > > > "[[:alpha:]][[:alnum:]._]*[[:alnum:]]" > > > > I realize that historically `_` has not always been valid in variable > > names, but this has now been acceptable for 15+ years (since R 1.9.0 I > > believe). Might we also allow underscores for package names? > > > > Jim > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > -- > Kevin Wright > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]