Editions
Steven Schveighoffer
schveiguy at gmail.com
Mon Apr 7 03:43:58 UTC 2025
On Wednesday, 2 April 2025 at 12:52:59 UTC, Dukc wrote:
> On Tuesday, 1 April 2025 at 16:21:59 UTC, Atila Neves wrote:
>> https://github.com/atilaneves/DIPs/blob/editions/editions.md
>
>> Modules without a module declaration would be considered to be
>> using the latest edition unless the default edition is
>> specified explicitly with a command line argument.
>
> Why? I see no reason that they shouldn't behave like the
> modules with editionless declaration at the top.
I think this might be my fault. In a long-ago review of the
original editions, my concern was about *playground code*, or
simply trying out the langauge.
Instead of having to first learn how to specify editions, one
should be able to use the language as it is currently specified.
Basically, if you write a hello world program, or play with
features, they should operate as documented, not as they were 2,
3, 10 years ago.
My recommendation was that the compiler would *default* to using
the current edition, if no edition was specified on the module.
However, dub would behave differently and specify a default
edition that is the pre-edition edition. This way, the thousands
of dub configurations out there that existed before editions
existed would default to the language at that level.
However, it seems this proposal goes a step further, and I agree,
a confusing one. It is not hard to evolve playground code into a
level that requires adding module declarations. I don't see why
these need to be for the OG edition.
I think the default edition if none is specified should always be
the latest. You can always change that with a compiler switch.
>> Another compiler switch to aid transitioning that this DIP
>> recommends is a -E switch which would function like -I for
>> imports but would allow the user to specify what the edition
>> should be for those imports.
>
> Does this override the edition at the module declaration?
I would say no. The purpose of this is for build systems to allow
setting the default edition package-wide.
Think of a dub package you are using that uses edition 2025, but
you are on edition 2026. There are no edition specifiers in the
modules, it's done all through the build system (dub). So when
you import those modules, you need to specify the default edition
just for those imports.
-Steve
More information about the dip.development
mailing list