[Rd] Feature request: Allow comma after last element in a list
@vi@e@gross m@iii@g oii gm@ii@com
@vi@e@gross m@iii@g oii gm@ii@com
Fri May 1 14:47:57 CEST 2026
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> On Behalf Of Mossa Merhi Reimert via R-devel
Sent: Friday, May 1, 2026 2:52 AM
To: Tomek Gieorgijewski <cybergeorge2020 using gmail.com>; Duncan Murdoch <murdoch.duncan using gmail.com>
Cc: 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> on behalf of Tomek Gieorgijewski <cybergeorge2020 using gmail.com>
Date: Thursday, 30 April 2026 at 21.36
To: Duncan Murdoch <murdoch.duncan using gmail.com>
Cc: Manfred Kooistra <manfred.kooistra using gmail.com>; r-devel using r-project.org <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>
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/ .
>
> 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>
> > 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 mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
[[alternative HTML version deleted]]
______________________________________________
R-devel using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[[alternative HTML version deleted]]
More information about the R-devel
mailing list