Skip to content

Package modules should not introduce new symbols #10800

Open
@Ogi-kun

Description

@Ogi-kun

Module packages are allowed to combine overload sets, but they should never introduce new public symbols.

Consider the following package:

lib
  | a.d
  | b.d
  | package.d
// lib/a.d
module lib.a;
void fooA();
// lib/b.d
module lib.b;
void fooB();
// lib/package.d
module lib;
public import lib.a;
public import lib.b;
void bar();

If the user wants to use lib.bar, he is forced to also import lib.a and lib.b.

The solution is to move bar to a separate module that the package module will publicly import. This module may have some generic name like lib/utils.d, or the same name as the package: lib/lib.d.

Offending modules in Phobos:

  • std.container
  • std.digest
  • std.experimental.allocator
  • std.format
  • std.range
  • std.regex
  • std.uni

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions