Compile-time reflection

Kirk McDonald kirklin.mcdonald at gmail.com
Wed Jul 11 11:29:59 PDT 2007


Bruno Medeiros wrote:
> Ok, I don't think I made my point correctly. Yes, it's useful to 
> distinguish between virtual, static and final member functions[*], but 
> that's something that could be done (if not already) with 
> is-expressions. What I mean is more about this:
> "An important rule of function overloading works in our favor, here: A 
> given function symbol can only refer to functions which are all virtual, 
> all static, or all final."
> Why would we want this change?
> 

I had somehow been mistaken that this was the way it worked currently. 
Whoops.

Since this isn't true, the StaticExpression syntax would have to specify 
the particular overload to operate on, something like:

StaticExpression:
     static ( Symbol Type == SymbolSpecialization )

Where Type is the signature of the overload to operate on, as in:

class C {
     void foo() {}
     static void foo(int i) {}
}

static(C.foo void function() == virtual) // true
static(C.foo void function(int) == static) // true

Specifying an non-existent overload should probably be an error.

> 
> [*] Although, I'm not so sure about virtual vs. final distinctions.
> 

As I said, this distintion may be important if you're doing certain 
tricks with inheritance. And if these mechanisms are being added, I 
don't think there's any reason /not/ to add it.

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org



More information about the Digitalmars-d mailing list