From: ko1@atdot.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:91402] [Ruby trunk Feature#15574] Prohibit to pass a block on super() implicitly
Date: Tue, 05 Feb 2019 02:02:57 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-76658.20190205020255.fe1306b1485d7a30@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15574.20190130071217@ruby-lang.org
Issue #15574 has been updated by ko1 (Koichi Sasada).
marcandre (Marc-Andre Lafortune) wrote:
> Is there an actual use case for thinking about removing it (besides it being quirky)?
I assume this spec is because of historical reason. Block parameter is introduced ruby-1.1b9_01, but maybe Matz wanted to pass block to initialize method (it's my speculation).
Exceptional rule is difficult to learn, so if we have no reason to keep compatibility, I want to remove this exceptional rule.
> I would bet that there are way more methods calling super with the block intact than the reverse. I will frequently prepend a method that intercepts a parameter, for example, deals with it and call `super` with the rest:
>
> ``` ruby
> def foo(*args, **options, extra_opt: nil)
> puts "extra!" if extra_opt
> super(*args, **options)
> end
> ```
I want to clarify this spec is desired or not.
Why don't you pass a block parameter explicitly?
Because you know the spec and intentional, or simply forget to pass it (and working it with this spec fortunately)?
----------------------------------------
Feature #15574: Prohibit to pass a block on super() implicitly
https://bugs.ruby-lang.org/issues/15574#change-76658
* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
As described in [Feature #15554], `super()` (not `super`) pass the given block.
```
class C
def foo
p block_given?
end
end
class C1 < C
def foo
super #=> true
super() #=> true
end
end
C1.new.foo{}
```
`super` (without parameters) passes all passed parameters so it is no surprise to pass given block.
However, `super()` (with parameters. In this case, it passes 0 parameters) also pass given block implicitly.
I'm not sure who use this behavior, but I think it is simple to prohibit such implicit block passing.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2019-02-05 2:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15574.20190130071217@ruby-lang.org>
2019-01-30 7:12 ` [ruby-core:91332] [Ruby trunk Feature#15574] Prohibit to pass a block on super() implicitly ko1
2019-01-30 10:12 ` [ruby-core:91335] " Webhostingonedollar102
2019-01-30 10:17 ` [ruby-core:91336] " Webhostingonedollar102
2019-01-30 12:12 ` [ruby-core:91338] " eregontp
2019-02-04 18:25 ` [ruby-core:91394] " ruby-core
2019-02-05 2:02 ` ko1 [this message]
2019-02-05 3:27 ` [ruby-core:91403] " duerst
2019-02-05 4:42 ` [ruby-core:91404] " sawadatsuyoshi
2019-02-15 10:20 ` [ruby-core:91558] " mail
2019-02-15 10:48 ` [ruby-core:91562] " sawadatsuyoshi
2019-02-15 11:02 ` [ruby-core:91563] " mail
2019-02-15 11:10 ` [ruby-core:91564] " sawadatsuyoshi
2019-02-15 11:42 ` [ruby-core:91566] " eregontp
2019-02-15 11:46 ` [ruby-core:91567] " mail
2019-10-21 8:14 ` [ruby-core:95451] [Ruby master " ko1
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.journal-76658.20190205020255.fe1306b1485d7a30@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).