* [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...)
@ 2022-11-17 9:27 shugo (Shugo Maeda)
2022-11-28 8:16 ` [ruby-dev:52003] " shugo (Shugo Maeda)
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: shugo (Shugo Maeda) @ 2022-11-17 9:27 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been reported by shugo (Shugo Maeda).
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134
* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52003] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
@ 2022-11-28 8:16 ` shugo (Shugo Maeda)
2022-11-28 22:39 ` [ruby-dev:52004] " matz (Yukihiro Matsumoto)
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: shugo (Shugo Maeda) @ 2022-11-28 8:16 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by shugo (Shugo Maeda).
I've created a pull request: https://github.com/ruby/ruby/pull/6818
With this change a test of rbs.gem fails because argument types of` def foo(...)` is changed to `(*untyped, **untyped **)` from `(*untyped)`, but I believe it's right.
(however, the specifal variable name `**` should be hidden by rbs.gem.)
I've created a issue: https://github.com/ruby/rbs/issues/1163
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100289
* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52004] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
2022-11-28 8:16 ` [ruby-dev:52003] " shugo (Shugo Maeda)
@ 2022-11-28 22:39 ` matz (Yukihiro Matsumoto)
2022-11-29 2:57 ` [ruby-dev:52006] " shugo (Shugo Maeda)
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: matz (Yukihiro Matsumoto) @ 2022-11-28 22:39 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by matz (Yukihiro Matsumoto).
LGTM.
Matz.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100293
* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52006] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
2022-11-28 8:16 ` [ruby-dev:52003] " shugo (Shugo Maeda)
2022-11-28 22:39 ` [ruby-dev:52004] " matz (Yukihiro Matsumoto)
@ 2022-11-29 2:57 ` shugo (Shugo Maeda)
2022-12-04 18:04 ` [ruby-dev:52009] " Eregon (Benoit Daloze)
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: shugo (Shugo Maeda) @ 2022-11-29 2:57 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by shugo (Shugo Maeda).
matz (Yukihiro Matsumoto) wrote in #note-2:
> LGTM.
Thank you. I've merged it.
I realized that my fix also chaged the behavior of the following code:
```ruby
def foo(*, **, &)
bar(...)
end
def bar(*args, **kw, &block)
p [args, kw, block&.call]
end
foo(1, 2, x: 3, y: 4) { 5 }
```
My fix changed the result from `[[1, 2], {}, 5]` to `[[1, 2], {:x=>3, :y=>4}, 5]`.
So `...` is now a syntax sugar of `*, **, &`.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100306
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52009] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (2 preceding siblings ...)
2022-11-29 2:57 ` [ruby-dev:52006] " shugo (Shugo Maeda)
@ 2022-12-04 18:04 ` Eregon (Benoit Daloze)
2022-12-04 18:08 ` [ruby-dev:52010] " Eregon (Benoit Daloze)
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-12-04 18:04 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by Eregon (Benoit Daloze).
IMHO if `...` is used then `*`, `**` and `&` should all be forbidden (a SyntaxError at parse time).
Because that way is the best for optimizing delegation.
And also taking apart `*` and `**` is arguably not really delegation anymore.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100486
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52010] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (3 preceding siblings ...)
2022-12-04 18:04 ` [ruby-dev:52009] " Eregon (Benoit Daloze)
@ 2022-12-04 18:08 ` Eregon (Benoit Daloze)
2022-12-04 22:48 ` [ruby-dev:52011] " shugo (Shugo Maeda)
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-12-04 18:08 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by Eregon (Benoit Daloze).
Although, it should still be possible to optimize delegation as good as possible and allow `*`/`**`/`&` by having those behave like `def args(*,**,&) = *`, `def kwargs(*,**,&) = **`, `def block(*,**,&) = &` and as if `*` was replaced by `args(...)`, etc, but that's of course at the expense of making the handling of those slightly slower and more complicated (but at least it doesn't slow down delegation via `(...)`).
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100489
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52011] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (4 preceding siblings ...)
2022-12-04 18:08 ` [ruby-dev:52010] " Eregon (Benoit Daloze)
@ 2022-12-04 22:48 ` shugo (Shugo Maeda)
2022-12-04 23:46 ` [ruby-dev:52012] " shugo (Shugo Maeda)
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: shugo (Shugo Maeda) @ 2022-12-04 22:48 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by shugo (Shugo Maeda).
Eregon (Benoit Daloze) wrote in #note-5:
> IMHO if `...` is used then `*`, `**` and `&` should all be forbidden (a SyntaxError at parse time).
> Because that way is the best for optimizing delegation.
> And also taking apart `*` and `**` is arguably not really delegation anymore.
`&` is allowed in 3.1, so it's a breaking change to prohibit it.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100493
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52012] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (5 preceding siblings ...)
2022-12-04 22:48 ` [ruby-dev:52011] " shugo (Shugo Maeda)
@ 2022-12-04 23:46 ` shugo (Shugo Maeda)
2022-12-12 14:04 ` [ruby-dev:52021] " Eregon (Benoit Daloze)
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: shugo (Shugo Maeda) @ 2022-12-04 23:46 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by shugo (Shugo Maeda).
Status changed from Closed to Open
I think it's most conservative to probhibit `*` and `**`:
```
def foo(...)
bar(&) # OK
baz(*) # error
quux(**) # error
end
```
And a error should occur in the following code instead of dropping keyword arguments:
```
def foo(*, **, &)
bar(...)
end
def bar(*args, **kw, &block)
p [args, kw, block&.call]
end
foo(1, 2, x: 3, y: 4) { 5 }
```
What do you think, Matz?
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100495
* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52021] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (6 preceding siblings ...)
2022-12-04 23:46 ` [ruby-dev:52012] " shugo (Shugo Maeda)
@ 2022-12-12 14:04 ` Eregon (Benoit Daloze)
2022-12-14 7:12 ` [ruby-dev:52025] " mame (Yusuke Endoh)
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-12-12 14:04 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by Eregon (Benoit Daloze).
shugo (Shugo Maeda) wrote in #note-8:
> `&` is allowed in 3.1, so it's a breaking change to prohibit it.
Right and `&` is not problematic re performance, it's a completely separate argument anyway.
I agree with your proposal in your comment just above this one.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100573
* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 3.2
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52025] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (7 preceding siblings ...)
2022-12-12 14:04 ` [ruby-dev:52021] " Eregon (Benoit Daloze)
@ 2022-12-14 7:12 ` mame (Yusuke Endoh)
2022-12-15 12:26 ` [ruby-dev:52027] " shugo (Shugo Maeda)
2022-12-15 13:47 ` [ruby-dev:52028] " Eregon (Benoit Daloze)
10 siblings, 0 replies; 12+ messages in thread
From: mame (Yusuke Endoh) @ 2022-12-14 7:12 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by mame (Yusuke Endoh).
> IMHO if ... is used then *, ** and & should all be forbidden (a SyntaxError at parse time).
I agree with this. If you want to do that, you should take it with `def foo(*, **, &)`.
I feel that only `&` is acceptable since a block is implicitly passed. But I don't think `*` and `**` make sense inside `def foo(...)`.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100630
* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 3.2
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52027] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (8 preceding siblings ...)
2022-12-14 7:12 ` [ruby-dev:52025] " mame (Yusuke Endoh)
@ 2022-12-15 12:26 ` shugo (Shugo Maeda)
2022-12-15 13:47 ` [ruby-dev:52028] " Eregon (Benoit Daloze)
10 siblings, 0 replies; 12+ messages in thread
From: shugo (Shugo Maeda) @ 2022-12-15 12:26 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by shugo (Shugo Maeda).
mame (Yusuke Endoh) wrote in #note-12:
> I feel that only `&` is acceptable since a block is implicitly passed. But I don't think `*` and `**` make sense inside `def foo(...)`.
Speaking of implicity of blocks, `def f; g(&); end` causes a syntax error, so it may be better to allow it, or disallow `def f(...); g(&); end` in the future versions.
Anyway, I've fixed the behavior of `...` as described in #note-9.
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100678
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 3.2
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [ruby-dev:52028] [Ruby master Feature#19134] ** is not allowed in def foo(...)
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
` (9 preceding siblings ...)
2022-12-15 12:26 ` [ruby-dev:52027] " shugo (Shugo Maeda)
@ 2022-12-15 13:47 ` Eregon (Benoit Daloze)
10 siblings, 0 replies; 12+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-12-15 13:47 UTC (permalink / raw)
To: ruby-dev
Issue #19134 has been updated by Eregon (Benoit Daloze).
shugo (Shugo Maeda) wrote in #note-14:
> Speaking of implicity of blocks, `def f; g(&); end` causes a syntax error, so it may be better to allow it, or disallow `def f(...); g(&); end` in the future versions.
Since some time @ko1 worked on no implicit block if not a parameter of the method (with the exception of `yield` in the body). I think that's a good property, so I think it's good for `def f; g(&); end` to be a syntax error.
For `def f(...); g(&); end` "..." is "capture all arguments, positional, keyword and block" so I think it's more natural there to be able to access the block (although I can't think of when that would be useful, maybe `def f(...); g(&); h(...) end` when `h` is known to ignore the block but that feels hacky, better use `(*, **, &)` parameters then).
> Anyway, I've fixed the behavior of `...` as described in #note-9.
Thanks!
----------------------------------------
Feature #19134: ** is not allowed in def foo(...)
https://bugs.ruby-lang.org/issues/19134#change-100680
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 3.2
----------------------------------------
`*` and `&` are allowed in the body of a method with `...` argument forwarding, but `**` is not allowed.
```
def foo(...)
bar(*) # OK
baz(&) # OK
quux(**) # NG
end
```
Is it intended behavior?
It seems that parse.y has code like `#ifdef RUBY3_KEYWORDS`, and if RUBY3_KEYWORDS, `**` will also be supported.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-12-15 13:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 9:27 [ruby-dev:51203] [Ruby master Feature#19134] ** is not allowed in def foo(...) shugo (Shugo Maeda)
2022-11-28 8:16 ` [ruby-dev:52003] " shugo (Shugo Maeda)
2022-11-28 22:39 ` [ruby-dev:52004] " matz (Yukihiro Matsumoto)
2022-11-29 2:57 ` [ruby-dev:52006] " shugo (Shugo Maeda)
2022-12-04 18:04 ` [ruby-dev:52009] " Eregon (Benoit Daloze)
2022-12-04 18:08 ` [ruby-dev:52010] " Eregon (Benoit Daloze)
2022-12-04 22:48 ` [ruby-dev:52011] " shugo (Shugo Maeda)
2022-12-04 23:46 ` [ruby-dev:52012] " shugo (Shugo Maeda)
2022-12-12 14:04 ` [ruby-dev:52021] " Eregon (Benoit Daloze)
2022-12-14 7:12 ` [ruby-dev:52025] " mame (Yusuke Endoh)
2022-12-15 12:26 ` [ruby-dev:52027] " shugo (Shugo Maeda)
2022-12-15 13:47 ` [ruby-dev:52028] " Eregon (Benoit Daloze)
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).