Bug?: Presence of "init()" Method Causes std.array.appender to Fail to Compile

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon May 14 19:01:55 UTC 2018


On Monday, May 14, 2018 18:29:33 David Nadlinger via Digitalmars-d wrote:
> On Monday, 14 May 2018 at 11:53:44 UTC, Nick Treleaven wrote:
> > On Monday, 14 May 2018 at 01:20:38 UTC, Jonathan M Davis wrote:
> >> Yeah. It's been discussed that it should be illegal to declare
> >> a struct or class member named init, but that change has yet
> >> to happen.
> >>
> >> https://issues.dlang.org/show_bug.cgi?id=7066
> >
> > Walter and Timon have considered redefinition potentially
> > useful. A compromise would be to require `init` and `stringof`
> > to be `static`. That would probably prevent the accidental
> > conflicts that arise with `init`.
>
> Well, Walter mentioned that "so far [no use cases] have
> materialized" in 2012, and I don't think that has changed since.
>
> @disabling .init might be an exception – although one that flirts
> with grey areas in the language definition –, but that could
> still be supported while providing useful diagnostics for other
> uses.

Well, @disable this(); specifically doesn't disable init (just default
initialization) specifically because so much depends on init existing (and
the fact that you can disable default initialization is already problematic
enough as it is). So, I'd be _very_ leery of adding a way to fully disable
init. However, even if we did want to do that, that doesn't preclude making
it illegal to define init to be something else.

- Jonathan M Davis




More information about the Digitalmars-d mailing list