Editions Ideas
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sat Jan 17 07:50:00 UTC 2026
On 17/01/2026 8:27 PM, libxmoc wrote:
> 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.
Unlike C, D default initializers variables, and has meta-programming.
The init property of a type is heavily used, removing it or swapping it
for a trait is not an option.
Also that @ syntax you come up with, conflicts with UDA's, and would be
seen as a function call.
More information about the Digitalmars-d
mailing list