WTF abstract is?

Timon Gehr timon.gehr at gmx.ch
Thu Nov 7 14:27:39 PST 2013


On 10/04/2013 08:22 AM, Ali Çehreli wrote:
>
>  >>
>  >> class B : A
>  >> {
>  >>     static if( __traits(isAbstractClass, typeof(this) ))
>  >
>  > this is invalid here. Not sure what you try to achieve via this
> static if.
>
> Well, obviously that is the reason for the bug. :) I think Zhouxuan
> thinks that it is an 'abstract' bug but actually it is some sort of
> __traits caching issue.
>
> It would indeed be weird for isAbstractClass to delay its value until
> the whole class definition is seen.
> ...

It has to delay it's value until it has seen as much as possible without 
knowing it. Then eg. emit a compile time error if the body of the static 
if actually changes the determined fact. (Or use some sound relaxation 
of that rule.) Many compile-time reflection features can be used to 
provoke this kind of issue. (E.g. write a class that subclasses another 
class iff it cannot access some protected field of it.)


More information about the Digitalmars-d mailing list