Project

General

Profile

Actions

Feature #19377

closed

Rename Fiber#storage to Fiber.storage

Added by zverok (Victor Shepelev) over 1 year ago. Updated about 1 year ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:112041]

Description

Justification:

  • #storage, which pretends to be an instance method, is always available only on Fiber.current, which is problematic to document, and needs special handling when storage is called for non-current Fiber;
  • with class method + docs "storage of the current fiber" it all will be self-evident;
  • Most of the time, when we declare methods that are available only in the current {something}, they are class methods. (like storage's itself interface of Fiber::[] and Fiber::[]=, or Module.used_modules, which is modules and refinements of the current context, but it is not self.used_modules, for example)
  • Code like
Fiber.current.storage = {foo: 'bar'}
Fiber[:foo]

...looks like it is two unrelated things (storage of the current fiber vs some "global" key getter/setter?)

I don't see much discussion of this in #19078. Matz in #19078#note-22, while accepting the interface, describes it as homogenous:

(1) fiber[key]/fiber[key]=val - accepted.
(2) fiber.storage => hash - accepted
(3) fiber.storage=hash - should be experimental
...

So I believe it should be either Fiber.current[] and Fiber.current.storage, or Fiber[], and Fiber.storage. The latter is preferable to underline it is only one, related to the current fiber, interface, not "every fiber instance has one (but actually you can use only current's)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0