[Rd] Feature request: Allow comma after last element in a list

Bemis, Kylie k@bem|@ @end|ng |rom northe@@tern@edu
Fri May 1 22:44:58 CEST 2026


I realized that implementation could allow multiple extra commas anywhere.

Here is a fixed version.

list0 <- function(...)
{
dots <- match.call(expand.dots=FALSE)$...
valid <- vapply(dots, nzchar, logical(1L))
if ( any(!valid[-length(valid)]) ) {
stop("YOU ONLY GET 1 TRAILING COMMA; STOP IT")
}
valid <- which(valid)
ans <- vector("list", length=length(valid))
for ( i in seq_along(valid) ) {
ans[[i]] <- ...elt(valid[i])
}
ans
}

~~~
Kylie Ariel Bemis (she/her)
Assistant Teaching Professor
Khoury College of Computer Sciences
Northeastern University
kuwisdelu.github.io<https://kuwisdelu.github.io/>










On May 1, 2026, at 4:18 PM, Bemis, Kylie <k.bemis using northeastern.edu> wrote:

I don’t know if this is the best way to do this, but if anyone really wants, here you go.

list0 <- function(...)
{
dots <- match.call(expand.dots=FALSE)$...
valid <- which(vapply(dots, nzchar, logical(1L)))
ans <- vector("list", length=length(valid))
for ( i in seq_along(valid) )
ans[[i]] <- ...elt(valid[i])
ans
}

# > list0(1,2,)
# [[1]]
# [1] 1

# [[2]]
# [1] 2

~~~
Kylie Ariel Bemis (she/her)
Assistant Teaching Professor
Khoury College of Computer Sciences
Northeastern University
kuwisdelu.github.io<https://kuwisdelu.github.io/>










On May 1, 2026, at 3:18 PM, avi.e.gross using gmail.com wrote:

Mossa,

I was expressing my reaction to the way you are saying what others should do, including thousands of packages that are not even well maintained. Not being one of the people who would be doing the work, I wondered how you get the request to those who might.

Others have pointed out the anomalies that may happen. I have used many programming languages over the years and some are designed in ways I do not like as much as other ways. Some end up being cautious and not making much have defaults and forcing users to specify clearly what they want. Others choose defaults and later get complaints. I can even imagine someone releasing a new function name simply to over-ride a default while not having to type it explicitly, Look carefully at something like the read.table() set of functions as examples of front-ends that reset defaults for specific kinds of files.

There is no right or wrong answer that pleases everybody but it generally is bad form to change something after years of use by flipping the default.

I can see merit in something a bit different such as when you have  slimmer paste0() function added alongside paste(). I can imagine creating a c0() alongside c that tolerates dangling commas. But then you may need a list0() and  perhaps quite a few more to be used when you want commas evaluated differently. It could be better to create one function, a bit like I() with some name like comma_safe() so you could wrap anything you want like this:

Myvec <- c(comma_safe(1,2,3,))

Only people who really feel a need would opt to use it. Even then, such a feature might mostly be useful while prototyping your code when you may be adjusting things by adding, deleting and re-arranging.

I do suggest that a valid case has been made why allowing dangling comments is a reasonable feature of a language and that it takes more than a one-liner request to specify what a change would look like.

Specifically, is the request limited to one trailing comma? What if it ends in three? What if the first or some middle spot has an extra comma? Where would this be applied? I mean there are many places comma separated lists are used. Function argument lists are a crucial example where every comma currently has meaning, especially for positional arguments. You cannot make a fifth argument became a third argument.

And note uses of commas in other places outside R like a CSV file. Over there, when you read the file in, generally a missing item between adjacent commas or at the beginning or end, becomes some form of NA.

And, how do you address the suggestion that some people depend on current behavior to detect their errors? If you allow some form of trailing comma, do you issue at least a warning?

Many languages end up at points like this by adding some form of flag you can place in your environment that allows some control over some features. Would you suggest a designated way to either turn on the new feature or suppress it, such as:

options(allow_trailing_commas = FALSE)

Do note that some current features may need to be examined, such as what happens near a “…” and also that R often allows delayed evaluation so a function often passes on some of what it received, unchanged, to the surprise of the other function.

There may be more and nuanced ideas people can supply that can produce more such requirements and of course lots of changes that may have to be made to countless kinds of documentation such as man pages of functions, including manual pages.

So, even assuming there is a consensus to make a change that might satisfy your needs, I suggest it might take a long time to plan it fully and implement it to a full extent – especially as many package maintainers do not want to put a new release out too often and when they have not made any real changes.

Almost in amusement, I have a thought. I have written code that allows you to write programs in both R and python that sort of operate on a shared set of data. You could define some of your data structures where you want commas ignored, on the python side while the R side manipulates the data structures already properly read in using your rules, ….

It does not seem worth it to me.


From: Mossa Merhi Reimert <tpb398 using alumni.ku.dk<mailto:tpb398 using alumni.ku.dk>>
Sent: Friday, May 1, 2026 2:01 PM
To: avi.e.gross using gmail.com<mailto:avi.e.gross using gmail.com>; 'Tomek Gieorgijewski' <cybergeorge2020 using gmail.com<mailto:cybergeorge2020 using gmail.com>>; 'Duncan Murdoch' <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com>>
Cc: r-devel using r-project.org<mailto:r-devel using r-project.org>
Subject: Re: [Rd] Feature request: Allow comma after last element in a list

Thank you Ivan for your comments. I am going to think about it.
Also Duncan Murdoch, thank you very much for your comments.

I didn't know about nargs. here's what I learned:
(function(...) {nargs()})()
[1] 0
(function(...) {nargs()})(,)
[1] 2
(function(...) {nargs()})(,,)
[1] 3
(function(...) {nargs()})(,,,)
[1] 4
(function(...) {nargs()})(,,,,)
[1] 5
(function(...) {nargs()})(,,,,,)
[1] 6


Let me think about that.

And avi.e.gross: I am sorry man, I didn't finish my reply properly, and I still don't get what you're saying. If you see me in the real world, let's talk, in a slow way, so that we can understand
and empathize with each other. I just don't get it on text, it seems.





Sent from Outlook for Mac
From: avi.e.gross using gmail.com<mailto:avi.e.gross using gmail.com> <mailto:avi.e.gross using gmail.com>  <avi.e.gross using gmail.com<mailto:avi.e.gross using gmail.com> <mailto:avi.e.gross using gmail.com> >
Date: Friday, 1 May 2026 at 19.40
To: Mossa Merhi Reimert <tpb398 using alumni.ku.dk<mailto:tpb398 using alumni.ku.dk> <mailto:tpb398 using alumni.ku.dk> >; 'Tomek Gieorgijewski' <cybergeorge2020 using gmail.com<mailto:cybergeorge2020 using gmail.com><mailto:cybergeorge2020 using gmail.com> >; 'Duncan Murdoch' <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com> <mailto:murdoch.duncan using gmail.com> >
Cc: r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org>  <r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org> >
Subject: RE: [Rd] Feature request: Allow comma after last element in a list
Whether a change is easy or hard to make is an issue that can allow YOU to download the source code and make your own modified copy of R for your own use, Mossa. And, any code you then run under your version of R, will not necessarily be something you can share with others who want to run it under a more standard shared version in which it will not cause errors.

There is an implicit contract that people have with whoever works on the public version of R. That contract requires discussions and feedback on bug fixes, new features or changes in how a feature works. It requires careful documentation and often some level of testing to see who might be impacted and time to update their code so it keeps working. For truly optional features, it is often done over time. And, some old features are merely deprecated for a while before being removed.

Another language, called Python, decide to make some incompatible changes while people were using a version I will call 2.X and named the new version 3.0 and people who did not change their code were left with partial support in 2.X that was slated to end after a while. You could argue that this was a good choice in the long run.

R has tried to remain with one unified set of users and not ruin things, ot at least provide another easy migration route.

The fact that so many packages are created is not a negative but a feature of a language that allows and supports extensions while leaving the main body of common code reasonable.

And, as noted, not everyone sees allowing a dangling comma as a positive. The workarounds here are s simple as using NULL as a placeholder or using some package to create vectors and so on.

But, if R is not to your taste, fine. There are many other languages available and many of us here also use other languages depending on needs and circumstances.

And, do note, R has some serious features that are quite different than something like Python that make it possible to do some things easier, and vice versa. This means that blindly copying a feature from another language is not always something trivial or even welcomed.


From: Mossa Merhi Reimert <tpb398 using alumni.ku.dk<mailto:tpb398 using alumni.ku.dk> <mailto:tpb398 using alumni.ku.dk> >
Sent: Friday, May 1, 2026 12:35 PM
To: avi.e.gross using gmail.com<mailto:avi.e.gross using gmail.com> <mailto:avi.e.gross using gmail.com> ; 'Tomek Gieorgijewski' <cybergeorge2020 using gmail.com<mailto:cybergeorge2020 using gmail.com><mailto:cybergeorge2020 using gmail.com> >; 'Duncan Murdoch' <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com> <mailto:murdoch.duncan using gmail.com> >
Cc: r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org>
Subject: Re: [Rd] Feature request: Allow comma after last element in a list

Respectfully, this is really one of the strangest responses I've seen in my life.

rlang literally re-invents R in 25k LOC of R code.. what other language has dialects written in its own language, and quite popular at that? It is getting to a level of absurdity, that I am not sure
how anyone can defend at this point.

If adding dangling commas is a hard, demanding, engineering problem, then I guess someone has to take a serious look at the code base. I might want to interject myself here, and say, it's not hard.

There are important things that need to be done. A GC lock available through C-API.
Making the r runtime reentrant, instead this process wide mayhem that exists. `[`(,,drop=FALSE). Dropping libtool from the configure scripts, so things can build,
without checks that don't are not important anymore. Some sort of tracking of heap-allocation
so R instrumentation tools are not seeing half the situation. I don't know.. there's just much more that actually needs scoping, planning and evaluation.





Sent from Outlook for Mac
From: avi.e.gross using gmail.com<mailto:avi.e.gross using gmail.com> <mailto:avi.e.gross using gmail.com>  <avi.e.gross using gmail.com<mailto:avi.e.gross using gmail.com> <mailto:avi.e.gross using gmail.com> >
Date: Friday, 1 May 2026 at 14.48
To: Mossa Merhi Reimert <tpb398 using alumni.ku.dk<mailto:tpb398 using alumni.ku.dk> <mailto:tpb398 using alumni.ku.dk> >; 'Tomek Gieorgijewski' <cybergeorge2020 using gmail.com<mailto:cybergeorge2020 using gmail.com><mailto:cybergeorge2020 using gmail.com> >; 'Duncan Murdoch' <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com> <mailto:murdoch.duncan using gmail.com> >
Cc: r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org>  <r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org> >
Subject: RE: [Rd] Feature request: Allow comma after last element in a list
I find the attitude a bit disturbing that a carefully designed and altered language be changed just because and without serious consideration. Who will fund it if volunteers do not step forward is one example of a serious consideration. What other changes should be put off to make room?

The default for many years in computing in general, IMO, was that a dangling comma probably represented an error where a programmer had forgotten to add another item. Dangling commas were not only allowed but required in some cases like argument lists to a function with 5 required positional arguments in some cases given how things were done and adding yet another dangling comma would have represented a problem as it now would have six arguments.

Things have changed and perhaps many or all languages will eventually allow dangling commas in some situations. But on the hierarchy of needs, some may see other updates for R as a bit more needed and compelling. Look how long it took to reach adding a pipe feature that includes an aspect few enjoy using versus the other pipes that persist.

As for packages adjusting, I have no idea if many would have to, but you can be sure that if there is a problem, many won't adjust for some time and users might be left out in the cold or simply not be able to upgrade to the latest versions.

It is not a good idea to just do things.

Having said that, of course, it might be a nice thing to do once it has been properly evaluated. But it would not particularly improve my life as I am quite used to what it takes to edit a comma separated list without leaving dangling commas.

-----Original Message-----
From: R-devel <r-devel-bounces using r-project.org<mailto:r-devel-bounces using r-project.org> <mailto:r-devel-bounces using r-project.org> > On Behalf Of Mossa Merhi Reimert via R-devel
Sent: Friday, May 1, 2026 2:52 AM
To: Tomek Gieorgijewski <cybergeorge2020 using gmail.com<mailto:cybergeorge2020 using gmail.com> <mailto:cybergeorge2020 using gmail.com> >; Duncan Murdoch <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com> <mailto:murdoch.duncan using gmail.com> >
Cc: r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org>
Subject: Re: [Rd] Feature request: Allow comma after last element in a list

Honestly, I think R just needs to add these things. I don't know what the hold out is.
It seems so odd, not to just move on from this lack of last-element-comma.

`[`(drop=FALSE) should also be adopted.

Why can't R have these things? CRAN has no package versioning at all. All CRAN packages
can be adjusted to the change, and it would be all good.



Sent from Outlook for Mac
From: R-devel <r-devel-bounces using r-project.org<mailto:r-devel-bounces using r-project.org> <mailto:r-devel-bounces using r-project.org> > on behalf of Tomek Gieorgijewski <cybergeorge2020 using gmail.com<mailto:cybergeorge2020 using gmail.com> <mailto:cybergeorge2020 using gmail.com> >
Date: Thursday, 30 April 2026 at 21.36
To: Duncan Murdoch <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com> <mailto:murdoch.duncan using gmail.com> >
Cc: Manfred Kooistra <manfred.kooistra using gmail.com<mailto:manfred.kooistra using gmail.com> <mailto:manfred.kooistra using gmail.com> >; r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org>  <r-devel using r-project.org<mailto:r-devel using r-project.org> <mailto:r-devel using r-project.org> >
Subject: Re: [Rd] Feature request: Allow comma after last element in a list

Thank you for the link - definitely worth trying!

T.

czw., 30 kwi 2026 o 21:24 Duncan Murdoch <murdoch.duncan using gmail.com<mailto:murdoch.duncan using gmail.com> <mailto:murdoch.duncan using gmail.com> >
napisa�(a):


This is a great suggestion.  BTW, I think it would be possible to do
this in RStudio as well.  See their Addins page here:
https://rstudio.github.io/rstudioaddins/<https://rstudio.github.io/rstudioaddins/> <https://rstudio.github.io/rstudioaddins/<https://rstudio.github.io/rstudioaddins/>> &data=05%7C02%7Ctpb398%40alumni.ku.dk<http://40alumni.ku.dk/>%7Cae85de2ff156426ad76908dea77fdfb9%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C639132364817869564%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=ojTec59KVitsio9CF5Rdt12f6NGoi8UDtbH2gpRxynY%3D&reserved=0 .

Duncan Murdoch

On 2026-04-30 1:44 p.m., Tomek Gieorgijewski wrote:
Hi Manfred!

As I can see that you already maintain the habit to have one element per
line,
I would like to propose that you incorporate some editing scripts in your
editor
to help ease your frustration.
I believe trying to change R parser will only add more of that feeling :)
I don't know your editor but if it's vim, I can propose this edit to
.vimrc
file:
" ----
function! ListCommas() range
       if a:firstline < a:lastline
           " Add commas at the end from first to second to last line if
there's no comma yet
           execute a:firstline . "," . (a:lastline - 1) . 's/[^,]$/&,/e'
       endif
        " Delete comma from last line (if matched)
       execute a:lastline . 's/,$//e'
   endfunction

   vnoremap <leader>, :call ListCommas()<CR>
" ---

So, now if you rerun vim on your file you can swap, add, delete lines
from
the list as you wish,
and at the end you can highlight all elements lines of your list in
visual
mode and execute ListCommas
function on those lines with <leader>, shortcut.

Of course only if you maintain your structure of element per line and
trailing parenthesis at a seperate line.

I'm sure VS Code, Emacs and some other editors have similar abilities to
help you.
Unfortunately I don't know of any such possibility in RStudio.

regards,
Tomek.

pt., 24 kwi 2026 o 13:35 Manfred Kooistra <manfred.kooistra using gmail.com<mailto:manfred.kooistra using gmail.com> <mailto:manfred.kooistra using gmail.com> >
napisa�(a):

I've always been irritated that R doesn't allow a comma after the last
element in a "list":

a <- c(
+     1,
+     2,
+     3
+ )
a
[1] 1 2 3
b <- c(
+     1,
+     2,
+     3,
+ )
Error in c(1, 2, 3, ) : argument 4 is empty

This makes updating lists unnecessarily cumbersome, which I find I
frequently do, either when I test code and want to run it with lists of
varying elements or varying orders of elements or when I maintain lists
manually over time and have to add or delete elements from them.

Is there a reason for this behavior in R and might it not be a good idea
to change it?
______________________________________________
R-devel using r-project.org<mailto:R-devel using r-project.org> <mailto:R-devel using r-project.org>  mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel> <https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel>> &data=05%7C02%7Ctpb398%40alumni.ku.dk<http://40alumni.ku.dk/>%7Cae85de2ff156426ad76908dea77fdfb9%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C639132364817892997%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=cl8Rb5YnKdIr0N6fptlbm9nEWqn9orcdzCaAnckSma0%3D&reserved=0


     [[alternative HTML version deleted]]

______________________________________________
R-devel using r-project.org<mailto:R-devel using r-project.org> <mailto:R-devel using r-project.org>  mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel> <https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel>> &data=05%7C02%7Ctpb398%40alumni.ku.dk<http://40alumni.ku.dk/>%7Cae85de2ff156426ad76908dea77fdfb9%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C639132364817907466%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=SW9ZtK6DaWGOaAifCCRti7ApVSyREXTB3DgeDwG5tA0%3D&reserved=0



       [[alternative HTML version deleted]]

______________________________________________
R-devel using r-project.org<mailto:R-devel using r-project.org> <mailto:R-devel using r-project.org>  mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel> <https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel>> &data=05%7C02%7Ctpb398%40alumni.ku.dk<http://40alumni.ku.dk/>%7Cae85de2ff156426ad76908dea77fdfb9%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C639132364817921020%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=NGvNN9dmg1qkKlDp0rJ2q7HCcLuUKDCZxrzOea%2BvRoA%3D&reserved=0

       [[alternative HTML version deleted]]

[[alternative HTML version deleted]]

______________________________________________
R-devel using r-project.org<mailto:R-devel using r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel>



	[[alternative HTML version deleted]]



More information about the R-devel mailing list