T.init and @disable this

Jonathan M Davis jmdavisProg at gmx.com
Sat Oct 6 00:00:30 PDT 2012


On Saturday, October 06, 2012 02:54:23 Andrei Alexandrescu wrote:
> A possible solution is to allow T.init for uncopyable types as an
> unresolved reference: code can use it symbolically, but if it tries to
> actually do things with it at runtime that would be a link-time error.

This sounds like a great solution. Being able to disallow the init property 
where appropriate but still be able to use it with compile-time reflection 
would be fantastic. The issues with compile-time checks are the biggest 
problem that I've had with the idea of disabling init.

> Another solution would be to define T.init for uncopyable types as
> function that just throws if ever called.

A linker problem would be better than throwing IMHO.

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.

- Jonathan M Davis


More information about the Digitalmars-d mailing list