* [ruby-core:124797] [Ruby Feature#21875] Handling of trailing commas in lambda parameters
@ 2026-02-12 12:05 Earlopain (Earlopain _) via ruby-core
2026-02-12 13:17 ` [ruby-core:124799] " Eregon (Benoit Daloze) via ruby-core
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-12 12:05 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #21875 has been reported by Earlopain (Earlopain _).
----------------------------------------
Feature #21875: Handling of trailing commas in lambda parameters
https://bugs.ruby-lang.org/issues/21875
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
https://bugs.ruby-lang.org/issues/19107 was accepted, which is about trailing commands in method definitions.
lambdas were not explicitly mentioned but I wanted to confirm how they should behave with a trailing comma. Or if a trailing comma should even be accepted for them.
It's not clear to me since lambdas sometimes behave like blocks and sometimes more like methods. `->(...) {}` for example is syntax invalid (same as in blocks) but they do check their arity with blocks don't do.
If a trailing comma is accepted it can either
* be implicit splat like in `foo do |bar,|; end` or `foo do |bar|; end`. It would also mean that the trailing comma is only allowed after a positional argument.
* Just be ignored and be accepted in most places like for method definitions.
The first option would be rather useless in regards to https://bugs.ruby-lang.org/issues/19107 when you just want to add the comma for cleaner diffs. But I guess for lambdas this happens very rarely anyways.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:124799] [Ruby Feature#21875] Handling of trailing commas in lambda parameters
2026-02-12 12:05 [ruby-core:124797] [Ruby Feature#21875] Handling of trailing commas in lambda parameters Earlopain (Earlopain _) via ruby-core
@ 2026-02-12 13:17 ` Eregon (Benoit Daloze) via ruby-core
2026-02-12 17:00 ` [ruby-core:124802] " Hanmac (Hans Mackowiak) via ruby-core
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2026-02-12 13:17 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21875 has been updated by Eregon (Benoit Daloze).
There is also `lambda { |a,| a }` which as far as I can tell ignores the trailing comma:
```ruby
irb(main):015> proc { |a,| a }.call([1,2])
=> 1
irb(main):016> lambda { |a,| a }.call([1,2])
=> [1, 2]
irb(main):017> -> (a,) { a }
<internal:kernel>:168:in 'Kernel#loop': (irb):17: syntax error found (SyntaxError)
irb(main):020> proc { |a,| a }.call(1,2)
=> 1
irb(main):021> lambda { |a,| a }.call(1,2)
(irb):21:in 'block in <top (required)>': wrong number of arguments (given 2, expected 1) (ArgumentError)
irb(main):022> lambda { |a,*| a }.call(1,2)
=> 1
```
I think since there seems to be no need to change anything for lambdas/procs in this regard I would suggest to change nothing.
It's extremely rare to have a multi-line definition of lambda arguments, isn't it?
So let's not make the semantics more complicated or incompatible for such a case.
----------------------------------------
Feature #21875: Handling of trailing commas in lambda parameters
https://bugs.ruby-lang.org/issues/21875#change-116412
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
https://bugs.ruby-lang.org/issues/19107 was accepted, which is about trailing commands in method definitions.
lambdas were not explicitly mentioned but I wanted to confirm how they should behave with a trailing comma. Or if a trailing comma should even be accepted for them.
It's not clear to me since lambdas sometimes behave like blocks and sometimes more like methods. `->(...) {}` for example is syntax invalid (same as in blocks) but they do check their arity with blocks don't do.
If a trailing comma is accepted it can either
* be implicit splat like in `foo do |bar,|; end` or `foo do |bar|; end`. It would also mean that the trailing comma is only allowed after a positional argument.
* Just be ignored and be accepted in most places like for method definitions.
The first option would be rather useless in regards to https://bugs.ruby-lang.org/issues/19107 when you just want to add the comma for cleaner diffs. But I guess for lambdas this happens very rarely anyways.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:124802] [Ruby Feature#21875] Handling of trailing commas in lambda parameters
2026-02-12 12:05 [ruby-core:124797] [Ruby Feature#21875] Handling of trailing commas in lambda parameters Earlopain (Earlopain _) via ruby-core
2026-02-12 13:17 ` [ruby-core:124799] " Eregon (Benoit Daloze) via ruby-core
@ 2026-02-12 17:00 ` Hanmac (Hans Mackowiak) via ruby-core
2026-03-01 13:02 ` [ruby-core:124894] " nobu (Nobuyoshi Nakada) via ruby-core
2026-03-06 9:57 ` [ruby-core:124938] " Eregon (Benoit Daloze) via ruby-core
3 siblings, 0 replies; 5+ messages in thread
From: Hanmac (Hans Mackowiak) via ruby-core @ 2026-02-12 17:00 UTC (permalink / raw)
To: ruby-core; +Cc: Hanmac (Hans Mackowiak)
Issue #21875 has been updated by Hanmac (Hans Mackowiak).
there are functions that look for the amount of parameters that gets spooked by this:
data = {
'a' => 1,
'b' => 2,
'c' => 3
}
data.each &proc {|a,| p a } #=> "a", "b", "c"
data.each &lambda {|a,| p a }
["a", 1]
["b", 2]
["c", 3]
----------------------------------------
Feature #21875: Handling of trailing commas in lambda parameters
https://bugs.ruby-lang.org/issues/21875#change-116416
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
https://bugs.ruby-lang.org/issues/19107 was accepted, which is about trailing commands in method definitions.
lambdas were not explicitly mentioned but I wanted to confirm how they should behave with a trailing comma. Or if a trailing comma should even be accepted for them.
It's not clear to me since lambdas sometimes behave like blocks and sometimes more like methods. `->(...) {}` for example is syntax invalid (same as in blocks) but they do check their arity with blocks don't do.
If a trailing comma is accepted it can either
* be implicit splat like in `foo do |bar,|; end` or `foo do |bar|; end`. It would also mean that the trailing comma is only allowed after a positional argument.
* Just be ignored and be accepted in most places like for method definitions.
The first option would be rather useless in regards to https://bugs.ruby-lang.org/issues/19107 when you just want to add the comma for cleaner diffs. But I guess for lambdas this happens very rarely anyways.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:124894] [Ruby Feature#21875] Handling of trailing commas in lambda parameters
2026-02-12 12:05 [ruby-core:124797] [Ruby Feature#21875] Handling of trailing commas in lambda parameters Earlopain (Earlopain _) via ruby-core
2026-02-12 13:17 ` [ruby-core:124799] " Eregon (Benoit Daloze) via ruby-core
2026-02-12 17:00 ` [ruby-core:124802] " Hanmac (Hans Mackowiak) via ruby-core
@ 2026-03-01 13:02 ` nobu (Nobuyoshi Nakada) via ruby-core
2026-03-06 9:57 ` [ruby-core:124938] " Eregon (Benoit Daloze) via ruby-core
3 siblings, 0 replies; 5+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-03-01 13:02 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #21875 has been updated by nobu (Nobuyoshi Nakada).
Earlopain (Earlopain _) wrote:
> If a trailing comma is accepted it can either
>
> * be implicit splat like in `foo do |bar,|; end` or `foo do |bar|; end`. It would also mean that the trailing comma is only allowed after a positional argument.
Rather I think it should be allowed even after optional/rest/keyword/keyword-rest arguments in block parameters too.
----------------------------------------
Feature #21875: Handling of trailing commas in lambda parameters
https://bugs.ruby-lang.org/issues/21875#change-116553
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
https://bugs.ruby-lang.org/issues/19107 was accepted, which is about trailing commands in method definitions.
lambdas were not explicitly mentioned but I wanted to confirm how they should behave with a trailing comma. Or if a trailing comma should even be accepted for them.
It's not clear to me since lambdas sometimes behave like blocks and sometimes more like methods. `->(...) {}` for example is syntax invalid (same as in blocks) but they do check their arity with blocks don't do.
If a trailing comma is accepted it can either
* be implicit splat like in `foo do |bar,|; end` or `foo do |bar|; end`. It would also mean that the trailing comma is only allowed after a positional argument.
* Just be ignored and be accepted in most places like for method definitions.
The first option would be rather useless in regards to https://bugs.ruby-lang.org/issues/19107 when you just want to add the comma for cleaner diffs. But I guess for lambdas this happens very rarely anyways.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:124938] [Ruby Feature#21875] Handling of trailing commas in lambda parameters
2026-02-12 12:05 [ruby-core:124797] [Ruby Feature#21875] Handling of trailing commas in lambda parameters Earlopain (Earlopain _) via ruby-core
` (2 preceding siblings ...)
2026-03-01 13:02 ` [ruby-core:124894] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-03-06 9:57 ` Eregon (Benoit Daloze) via ruby-core
3 siblings, 0 replies; 5+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2026-03-06 9:57 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21875 has been updated by Eregon (Benoit Daloze).
nobu (Nobuyoshi Nakada) wrote in #note-4:
> Rather I think it should be allowed even after optional/rest/keyword/keyword-rest arguments in block parameters too.
Wouldn't that be **very** confusing then because `proc { |a,| a }.call([1,2]) => 1` splats but `proc { |a, kw: 1,| a }.call([1,2]) => [1, 2]` wouldn't splat? That is the comma would have very different meaning based on its position.
It seems far safer to keep things as-is, rather than introduce semantic ambiguity without even a use case for this change (multiline lambda/block parameters are very rare).
How about closing this for now (keep things as-is) since there is no use case and there are clear disadvantages/problems?
----------------------------------------
Feature #21875: Handling of trailing commas in lambda parameters
https://bugs.ruby-lang.org/issues/21875#change-116604
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
https://bugs.ruby-lang.org/issues/19107 was accepted, which is about trailing commands in method definitions.
lambdas were not explicitly mentioned but I wanted to confirm how they should behave with a trailing comma. Or if a trailing comma should even be accepted for them.
It's not clear to me since lambdas sometimes behave like blocks and sometimes more like methods. `->(...) {}` for example is syntax invalid (same as in blocks) but they do check their arity with blocks don't do.
If a trailing comma is accepted it can either
* be implicit splat like in `foo do |bar,|; end` or `foo do |bar|; end`. It would also mean that the trailing comma is only allowed after a positional argument.
* Just be ignored and be accepted in most places like for method definitions.
The first option would be rather useless in regards to https://bugs.ruby-lang.org/issues/19107 when you just want to add the comma for cleaner diffs. But I guess for lambdas this happens very rarely anyways.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-06 9:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12 12:05 [ruby-core:124797] [Ruby Feature#21875] Handling of trailing commas in lambda parameters Earlopain (Earlopain _) via ruby-core
2026-02-12 13:17 ` [ruby-core:124799] " Eregon (Benoit Daloze) via ruby-core
2026-02-12 17:00 ` [ruby-core:124802] " Hanmac (Hans Mackowiak) via ruby-core
2026-03-01 13:02 ` [ruby-core:124894] " nobu (Nobuyoshi Nakada) via ruby-core
2026-03-06 9:57 ` [ruby-core:124938] " Eregon (Benoit Daloze) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).