www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - WTF of the day: meta shenanigans

reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
So I'm designing a compile-time mechanism. I go:

// I have a few interfaces
interface W1 {}
interface Foo {}

// my class implements them
class X : W1, Foo {}

void foo(X a)
     // let me check if this code knows that X implements W1
     enum r = anySatisfy!((a => is(a == W1)), InterfacesTuple!X);

And it prints true. Great.
Ok, better make sure it prints false when X doesn't implement W1. 
So I change it:

class X : Foo {}

I run it and the output is...



What's the type of r now?

     pragma(msg, typeof(r));

And it outputs...

bool function(Foo a) pure nothrow  nogc  safe


And that concludes today's episode of WTF.
Jun 06 2018
parent =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Thursday, 7 June 2018 at 00:33:28 UTC, Luís Marques wrote:
 And that concludes today's episode of WTF.
BTW I understand what the problem was. I just wanted to publicly share my own incompetence :o)
Jun 06 2018