ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: aaronc20000@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96508] [Ruby master Feature#16456] Ruby 2.7 argument delegation (...) should be its own kind of parameter in Method#parameters
Date: Fri, 27 Dec 2019 00:42:16 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-16456.20191227004215.0eda6e1023e83d6d@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16456.20191227004215@ruby-lang.org

Issue #16456 has been reported by aaronc81 (Aaron Christiansen).

----------------------------------------
Feature #16456: Ruby 2.7 argument delegation (...) should be its own kind of parameter in Method#parameters
https://bugs.ruby-lang.org/issues/16456

* Author: aaronc81 (Aaron Christiansen)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
A method defined with `...` as its parameter list is equivalent to one defined with `*args, &blk`, according to `Method#parameters`.

```
def foo(...); end
p method(:foo).parameters
# => [[:rest, :*], [:block, :&]]
```

Even in Ruby 2.7, `...` and `*args, &blk` are not _quite_ equivalent as the latter may produce a warning where the former does not. In Ruby 3.0 and beyond, `...` and `*args, &blk` will have a substantial semantic difference. Due to this, I don't consider the current behaviour of `Method#parameters` particularly ideal when dealing with methods using this new syntax.

If the goal of `...` is to be a "delegate everything" operator, even when parameter passing is changed like in Ruby 3.0, I would propose that `Method#parameters` considers it a unique type of parameter. For example:

```
def foo(...); end
p method(:foo).parameters
# => [[:delegate, :"..."]]
```



-- 
https://bugs.ruby-lang.org/

       reply	other threads:[~2019-12-27  0:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-16456.20191227004215@ruby-lang.org>
2019-12-27  0:42 ` aaronc20000 [this message]
2019-12-27 11:29 ` [ruby-core:96511] [Ruby master Feature#16456] Ruby 2.7 argument delegation (...) should be its own kind of parameter in Method#parameters eregontp
2019-12-27 11:37 ` [ruby-core:96513] " zverok.offline
2019-12-27 17:35 ` [ruby-core:96517] " aaronc20000
2019-12-29 22:54 ` [ruby-core:96585] " daniel
2019-12-31 17:30 ` [ruby-core:96608] " aaronc20000

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-16456.20191227004215.0eda6e1023e83d6d@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).