Editions Ideas
libxmoc
libxmoc at gmail.com
Sat Jan 17 07:27:35 UTC 2026
On Friday, 16 January 2026 at 20:59:02 UTC, Nick Treleaven wrote:
> On Friday, 16 January 2026 at 18:23:05 UTC, Quirin Schroll
> wrote:
>> Replace magic properties with keywords and traits. For
>> example, `T.init` should be `default(T)`. The problem is that
>> you can define an eponymous member.
>
> I think removing support in an edition for `.init` would be
> very disruptive. Why not just ban redefining it?
> https://github.com/dlang/dmd/issues/18386
>
>> `T.sizeof` should be `__traits(sizeof, T)`.
>
> Redefining `sizeof` is already an error.
In C and virtually every other language, naming a function `init`
is extremely common. In D, defining an `init` symbol clashes with
the built-in `.init` property.
Rather than outright banning `init` as an identifier, an edition
is the perfect opportunity to finally return this name to users.
I propose: `@init(T)` or `__traits(init, T)` as the replacement.
More information about the Digitalmars-d
mailing list