[#91458] [Ruby trunk Feature#4475] default variable name for parameter — matz@...
Issue #4475 has been updated by matz (Yukihiro Matsumoto).
3 messages
2019/02/07
[ruby-core:91562] [Ruby trunk Feature#15574] Prohibit to pass a block on super() implicitly
From:
sawadatsuyoshi@...
Date:
2019-02-15 10:48:00 UTC
List:
ruby-core #91562
Issue #15574 has been updated by sawa (Tsuyoshi Sawada).
sos4nt (Stefan Schテシテ殕er) wrote:
> With the proposed change however, it becomes my responsibility. Almost every time I use `super(...)` I have to remember passing the block. The above code would become:
>
> ```ruby
> class B < A
> def initialize(foo, bar = nil, &block)
> # ...
> super(foo, &block)
> end
> end
> ```
In such case, i.e., when you don't want to take the responsibility of managing the arguments and blocks, I think you should use `super`, not `super(foo, &block)`. Using `super()` is a way to explicitly take care of the arguments, and it is counter-intuitive and inconsistent to let only the block be passed automatically.
----------------------------------------
Feature #15574: Prohibit to pass a block on super() implicitly
https://bugs.ruby-lang.org/issues/15574#change-76825
* 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/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>