Issue #19047 has been updated by matz (Yukihiro Matsumoto).
Sorry, but by this change, we missed the warnings from DelegateClass misuse. We will revert this change.
Matz.
----------------------------------------
Bug #19047: DelegateClass displays "method redefined" warning when overriding methods
https://bugs.ruby-lang.org/issues/19047#change-100373
* Author: jonathanhefner (Jonathan Hefner)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.1.2p20
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Perhaps this is not a bug, but it does seem unexpected.
When creating a `DelegateClass` class without an intervening ancestor, overriding a method displays "method redefined" warning:
```ruby
Base = Class.new do
def foo
"foo"
end
end
Delegate1 = DelegateClass(Base) do
def foo
super + "1"
end
end
# warning: method redefined; discarding old foo
Delegate2 = Class.new(DelegateClass(Base)) do
def foo
super + "2"
end
end
# no warning
Delegate1.new(Base.new).foo
# => "foo1"
Delegate2.new(Base.new).foo
# => "foo2"
```
One possible solution would be to evaluate the `DelegateClass` block in a separate module, and prepend that module to the returned class.
Another possible solution would be to silence warnings around [when the block is evaluated](https://github.com/ruby/delegate/blob/df2283b8d8874446086b80355c….
I would be happy to submit a PR to https://github.com/ruby/delegate if this is something we want to address.
--
https://bugs.ruby-lang.org/
Issue #19079 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Rejected
The `DelegateClass` defines an anonymous class and defines forwarding methods to the class. The reported (so-called) issue is a natural consequence of the above behavior. `include` add methods defined in a module **above** the current class, so forwarding methods have higher precedence. If you (re)define a method, it overwrites the forwarding method.
My opinion is that your assumption is wrong, so we don't need to fix. If you think we need to implement your assumption, you need to persuade us with the real world use-case.
Matz.
----------------------------------------
Bug #19079: Modules included in a DelegateClass cannot override delegate methods
https://bugs.ruby-lang.org/issues/19079#change-100371
* Author: jonathanhefner (Jonathan Hefner)
* Status: Rejected
* Priority: Normal
* ruby -v: ruby 3.1.2p20
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Because `DelegateClass` defines delegate methods on the class itself, those delegate methods come first in the method lookup chain. This prevents included modules from overriding delegate methods:
```ruby
Base = Class.new do
def foo
"base"
end
end
Helper = Module.new do
def foo
"helper"
end
end
WithHelper = DelegateClass(Base) { include Helper }
WithHelper.new(Base.new).foo
# => "base"
```
One possible solution would be to define the delegate methods in a separate module. That way, other modules could come before it in the method lookup chain.
--
https://bugs.ruby-lang.org/
Issue #19078 has been updated by matz (Yukihiro Matsumoto).
This proposal contains 4 features:
(1) fiber[key]/fiber[key]=val - accepted.
(2) fiber.storage => hash - accepted
(3) fiber.storage=hash - should be experimental
(4) Fiber.new(...,storage: hash|true|false|nil) - accepted, but true/false should be experimental
The feature (3) can be bigger side effect to clear third-party storage, so we need some experiment.
The feature (4) with true/false are hard to read the intention (true to inherit with dup, false to inherit without dup), so we need experiment here as well.
Matz.
----------------------------------------
Feature #19078: Introduce `Fiber#storage` for inheritable fiber-scoped variables.
https://bugs.ruby-lang.org/issues/19078#change-100370
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
----------------------------------------
Pull Request: https://github.com/ruby/ruby/pull/6612
This is an evolution of the previous ideas:
- https://bugs.ruby-lang.org/issues/19058
- https://bugs.ruby-lang.org/issues/19062
This PR introduces fiber scoped variables, and is a solution for problems like <https://github.com/ioquatix/ioquatix/discussions/17>.
The main interface is:
```ruby
Fiber[key] = value
Fiber[key] # => value
```
The variables are scoped (local to) a fiber and inherited into child fibers and threads.
```ruby
Fiber[:request_id] = SecureRandom.hex(16)
Fiber.new do
p Fiber[:request_id] # prints the above request id
end
```
The fiber scoped variables are stored and can be accessed:
```ruby
Fiber.current.storage # => returns a Hash (copy) of the internal storage.
Fiber.current.storage= # => assigns a Hash (copy) to the internal storage.
```
Fiber itself has one new keyword argument:
```
Fiber.new(..., storage: hash, false, undef, nil)
```
This can control how the fiber variables are setup in a child context.
To minimise the performance overhead of some of the implementation choices, we are also simultaneously implementing <https://bugs.ruby-lang.org/issues/19077>.
## Examples
### Request loop
```ruby
Thread.new do
while request = queue.pop
Fiber.new(storage: {id: SecureRandom.hex(16)}) do
handle_request.call(request)
end
end
end
```
OR
```ruby
Thread.new do
while request = queue.pop
Fiber.current.storage = {id: SecureRandom.hex(16)}
handle_request.call(request)
end
end
```
--
https://bugs.ruby-lang.org/
Issue #13721 has been updated by shugo (Shugo Maeda).
Status changed from Assigned to Rejected
Rejected because [Feature #13725] was reverted and not fixed yet.
----------------------------------------
Feature #13721: [PATCH] net/imap: dedupe attr keys in Net::IMAP::FetchData
https://bugs.ruby-lang.org/issues/13721#change-100369
* Author: normalperson (Eric Wong)
* Status: Rejected
* Priority: Normal
* Assignee: normalperson (Eric Wong)
----------------------------------------
Since attr hash keys are frequently reused, it makes sense to
deduplicate them up front.
This saves one allocation per-attr, per-message. When running
imap.fetch(1..-1, 'UID') on a mailbox with 30000 messages;
this saves 30000 allocations.
This relies on the String#-@ change in [Feature #13077]
* net/imap: use frozen, deduplicated string in attr name (key)
Trivial (1-byte change :), I may commit in a few days if no response.
---Files--------------------------------
0001-net-imap-dedupe-attr-keys-in-Net-IMAP-FetchData.patch (1 KB)
--
https://bugs.ruby-lang.org/