DeRailed DSL (was Re: compile-time regex redux)

Kirk McDonald kirklin.mcdonald at gmail.com
Sun Feb 11 01:32:23 PST 2007


Walter Bright wrote:
> Kirk McDonald wrote:
>> Given a class, I need a way to get a list of all of its member 
>> functions at compile-time.
> 
> static member functions? non-virtual member functions?

Okay, I think I do need to clarify this.

Let's take this class:

class Foo {
     void foo() {} // A regular method
     static void bar() {} // A static member function
     final void baz() {} // A non-virtual member function
}

Here's one possible interface:

get_member_functions!(Foo) => Tuple!(Foo.foo, Foo.bar, Foo.baz)

To distinguish between these attributes, we could define an enum, like:

enum MemberAttribute { Virtual, Final, Static }

Then we would have another template or built-in function or whatever 
these are supposed to be:

get_member_attributes!(Foo) => Tuple!(MemberAttribute.Virtual, 
MemberAttribute.Static, MemberAttribute.Final)

Where the order of this tuple's elements corresponds exactly to the 
first tuple's.

This is one idea. If anyone thinks of a better interface (and these 
names are probably unacceptable, at least), please speak up.

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



More information about the Digitalmars-d mailing list