Project

General

Profile

Actions

Misc #21385

open

Namespace: Suggesting a rename

Added by fxn (Xavier Noria) 2 days ago. Updated about 1 hour ago.

Status:
Open
Assignee:
-
[ruby-core:122343]

Description

I'd like to suggest a rename of namespaces.

The word "namespace" is already taken in Ruby.

We say that classes and modules act as or represent namespaces. Constant paths nest them in practice. We say that it is a best practice that gems create their own namespace, etc.

If the feature goes ahead with this name, the above sentences, well-established in the Ruby community, will start to sound confusing, because that meaning of "namespace" stays.

If you look at the index in Matz's book, "namespaces" is indexed in pages 248–250. Title of section 7.5.1 is "Modules as Namespaces".

Besides, I have had a few experiences explaining the proposal to people, and quickly realizing they assume this is something like C++ namespaces or Java packages. Then, I have to undo that mental model and start all over saying "forget that mental model". Those are like our constant paths, only more simple and strict. I think it may also be confusing in this sense (though this could be OK if it wasn't for the previous point.)

To be constructive: Some alternative names that I have thought about are "isolates", "shields", or "cells". ("sandboxes" is close, but may have security connotations you do not want to suggest.)

Actions #1

Updated by fxn (Xavier Noria) 2 days ago

  • Description updated (diff)

Updated by matheusrich (Matheus Richard) 2 days ago

Another suggestion: Context.

Updated by fxn (Xavier Noria) 2 days ago

More evidence.

The CRuby code base has the predicate rb_namespace_p (I think, since Ruby 2.7):

static inline bool
rb_namespace_p(VALUE obj)
{
    if (RB_SPECIAL_CONST_P(obj)) return false;
    switch (RB_BUILTIN_TYPE(obj)) {
      case T_MODULE: case T_CLASS: return true;
      default: break;
    }
    return false;
}

and now it has a macro with similar name, but different meaning:

#define IS_NAMESPACE(obj) (CLASS_OF(obj) == rb_cNamespace)

Updated by Eregon (Benoit Daloze) about 3 hours ago

Agreed naming this new feature Namespace is very confusing and misleading.
isolates doesn't sound right because they are not really isolated.
I think Context would be fine.
TruffleRuby has a similar feature called InnerContext (except those have separate heaps and are more like multiple interpreters + easy communication (notably enables passing an object from a context to another), but on a high semantics level it is very similar).

Updated by baweaver (Brandon Weaver) about 1 hour ago

Some other ideas:

  • Package - Some conflict with Packwerk, but then again would likely be used with it very quickly.
  • Capsule - Similar to Package
  • Realm - Bit Tolkien-esque, but no significant precedence in Ruby of this name being used.
  • Zone - Similar implications as Realm, but a bit less archaic.

Personally fond of Package, as it encapsulates a lot of what we would want out of such a feature, and also aligns with common tool usage that would be likely to leverage such features.

Context can be mixed with RSpec a bit, but probably not a huge issue.

Actions

Also available in: Atom PDF

Like2
Like0Like0Like0Like0Like0