Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

Editions

Contents
  1. Grammar

Editions provide a way to evolve D by obsoleting features while maintaining compatibility with code that uses those features. Editions are a module level feature, i.e. various sections of a module cannot be set to different editions.

The edition is set either by default, by putting it in the ModuleDeclaration, or with the -edition command line switch.

Editions are meant to be backwards and forwards compatible; it makes it possible for a D module targeting one edition to import a D module targeting any other edition. A template must obey the rules of the edition targeted by the module in which it is defined, not the module in which it is instantiated. Compatibility is at the source code level; no promises of ABI compatibility are made. All code, old and new, must be compiled with the same version of the compiler. Only one version of DRuntime, which must support all existing editions, is to be provided with a compiler release.

Grammar

Edition:
    DecimalInteger

What can editions do?

Specifying the Edition

An edition level is determined by:

  1. an explicit 4 digit number corresponding to the year in which the desired edition was released
  2. if no edition is specified, and there is no ModuleDeclaration in the source code, the edition used is the Baseline Edition, which corresponds to 2023.
  3. if no edition is specified, and there is a ModuleDeclaration in the source code, the edition used is the year the compiler was released.
Legacy Code