Skip to content

[RFC] Scopes for module/namespace access #1842

Open
@deathaxe

Description

@deathaxe

Intro

In general a trend/principle in syntax definitions can be found which ends up with scoping the declaration/definition of constructs with entity.name.<construct>. When calling/using such constructs, something like variable.<construct> or variable.other.<construct> is used.

The most popular example is entity.name.function vs. variable.function.

The goal is clear - distinguish definition and usage of the same object.

Question

How are namespaces or modules to handle in that manner?

A couple of syntaxes including C, C++, Python, PHP, Java, JavaScript, Erlang, ... support such concepts. Most of them use entity.name.namespace to scope the identifier in the definition/declaration statement as the ST3 documentation at https://www.sublimetext.com/docs/3/scope_naming.html says:

Namespaces, packages and modules use the following scope. There are usually not multiple types of such constructs in a language, so this scope should suffice.

entity.name.namespace

But I can't find a common solution how to scope a namespace/module upon usage.

    module_name:function_name()
  • C# distinguishes between support.namespace.cs and variable.other.namespace.cs
  • CSS uses entity.other.namespace-prefix.css or entity.name.namespace.wildcard.css
  • Erlang uses entity.name.type.class.module.erlang
  • Python just scopes them as meta.generic-name upon usage or meta.import-name in import statements.
  • ...

Can we find a common scope for that usage?

  1. From my point of view anything starting with entity. is a no-go when we talk about usage.

  2. The most pleasant approach with respect of existing scoping guidelines and implementations seems to be variable.other.namespace. So we'd end up in

    entity.name.namespace vs. variable.other.namespace

  3. To keep up with the concept of function declaration and usage, I also could imagine to use variable.namespace. So we'd end up in

    entity.name.namespace vs. variable.namespace

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions