"instanceOf" trait for conditional implementations

kenji hara k.hara.pg at gmail.com
Thu Oct 4 04:51:14 PDT 2012


2012/10/4 monarch_dodra <monarchdodra at gmail.com>:
> One of the issues I've been running into more or less frequently lately is
> the inability to extract an instance of a type when trying to do conditional
> implementation specification.
>
> Let me explain myself. Using T.init is a no go, because:
> a) T might be "@disabled this()", making T.init illegal syntax (in theory,
> currently "buggy")

I think T.init should always legal.

> b) T.init is NOT an LValue, making code such is "is(typeof(T.init = 5))"
> invalid

> c) You can try to use "T t = void", but you may also run into problems:
> c)1) If T is immutable, that's illegal.
> c)2) The compiler may complain if you use t, due to access to uninitialized.

IMO, this is just a compiler bug. If a variable has VoidInitializer,
it should always become a runtime value.

Kenji Hara


More information about the Digitalmars-d mailing list