T.init and @disable this

monarch_dodra monarchdodra at gmail.com
Sat Oct 6 01:16:20 PDT 2012


On Saturday, 6 October 2012 at 08:22:48 UTC, Jonathan M Davis 
wrote:
> On Saturday, October 06, 2012 17:06:07 kenji hara wrote:
>> 2012/10/6 Jonathan M Davis <jmdavisProg at gmx.com>:
>> > On Saturday, October 06, 2012 16:27:30 kenji hara wrote:
>> >> 2012/10/6 Jonathan M Davis <jmdavisProg at gmx.com>:
>> >> > Regardless, we need to better sort out how disabling init 
>> >> > works. It was
>> >> > my
>> >> > understanding that the correct way to do it was to do
>> >> > 
>> >> > @disable this();
>> >> > 
>> >> > but apparently that's in dispute (at least, Kenji doesn't 
>> >> > seem to think
>> >> > that that's supposed to disable the init property), and 
>> >> > it doesn't
>> >> > actually work.
>> >> 
>> >> My argue is simple: If your argument is proper behavior, 
>> >> you never
>> >> move NonNull object.
>> > 
>> > What does disabling init have to do with moving? If you're 
>> > moving an
>> > object, it already exists, so it doesn't need to be default 
>> > initialized.
>> 
>> Oh, sorry. I've talked about std.algorithm.move, didn't about 
>> proper
>> move in language semantics.
>
> Well, if you disable init, then naturally, anything which 
> requires it won't
> work, but Andrei's suggestion of having a disabled init still 
> work for static
> introspection but failing to link if used would catch that. 
> Ideally, it would
> compile with the static introspection but fail if ever actually 
> used in code,
> but that's probably too hard to do unfortunately,
>
> - Jonathan M Davis

Well, "instanceOf!T" or "defaultInit" (can) do exactly that.

http://d.puremagic.com/issues/show_bug.cgi?id=8762



More information about the Digitalmars-d mailing list