Skip to content

[SUGGESTION/RFC] Replace scope resolution operator '::' with member access operator '.' #1341

Open
@mhermier

Description

@mhermier

Hi,

The idea behind that change is to change/simplify the syntax of how we access namespaces components.
If the notion of namespace is shifted a little bit to an instantiated "static sparse struct", then the scope resolution operator '::' can simply be replaced with member access operator '.'.

PROS:

  • It unifies the syntax when accessing static/constexpr variables.
  • It simplify the teaching of the navigation in the symbol namespace by eliminating the special case of the scope operator.
  • It eases moving code from namespace variables to member variables. As such it should also be an opportunity to reduce diffs in scm.
  • It should also simplify tools like code generators, by unifying the syntax we don't need a special case for generating namespace member access.

CONS:

  • There might be some corner cases when trying to access types, but I'm quite convicted the ease of write surpass the burden of theses corner cases.
  • I wonder how error prone the unary left '.' operator can be when accessing the global scope.

For now I don't consider it a complete suggestion, but I wonder what other people think about that idea, hence the RFC.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions