spec icon indicating copy to clipboard operation
spec copied to clipboard

Prefer canonical qualified names for classes under `Thread`

Open nobu opened this issue 4 years ago • 6 comments

As the names show, Mutex, Queue, SizedQueue and ConditionVariable are defined under the Thread namespace, and the top level constants are aliases. Not to cause confusion, bundled files should use the canonical qualified names at least.

nobu avatar Oct 09 '21 15:10 nobu

What is the motivation behind this change?

AFAIK most users don't prefix with Thread:: for Queue and Mutex (unless the code is quite old).

I also don't think we can ever remove those top-level constants without causing major compatibility issues.

eregon avatar Oct 11 '21 13:10 eregon

On CRuby I see:

$ ruby -e 'p Queue'
Thread::Queue
$ ruby -e 'p Mutex'
Thread::Mutex

but on TruffleRuby:

$ ruby -e 'p Queue'
Queue
$ ruby -e 'p Mutex'
Mutex

I don't think it matters too much, but IMHO since the recent usages are predominantly without Thread:: I think that should be the canonical name.

eregon avatar Oct 11 '21 13:10 eregon

I've merged a9430c7 since that change makes sense no matter what we do next.

eregon avatar Oct 11 '21 13:10 eregon

@nobu Could you explain the motivation behind this change?

eregon avatar Oct 15 '21 14:10 eregon

@eregon Filled the description.

nobu avatar Oct 19 '21 07:10 nobu

@nobu Thanks, I think we should change the canonical names instead so they represent the usages better: https://bugs.ruby-lang.org/issues/18256

eregon avatar Oct 19 '21 09:10 eregon

Thank you for the PR. I decide to close this. AFAIK most usages by Ruby users are without the Thread:: prefix, and nesting seems to just make it harder to find specs for Mutex/Queue/SizedQueue (+ potential needless conflicts).

eregon avatar Oct 08 '22 11:10 eregon