D2 GUI Libs

Adam D. Ruppe destructionator at gmail.com
Mon Dec 14 07:37:36 PST 2009


On Mon, Dec 14, 2009 at 07:24:11AM -0800, Andrei Alexandrescu wrote:
> D2 will include properties that are understood by the compiler. We 
> currently don't have a design for user-defined properties.

Can I suggest something very simple: make them accessible from __traits,
and leave the rest to the library. Accept @anything_at_all.

@myprop int a;

assert(__traits(getAnnotations, a) == [ "myprop" ]);


That's all the compiler needs to do. Then, in the library, we combine it
with some magic to do the actual work. Something like this:

=========

class A {
	mixin(SIGNALS_AND_SLOTS!(A));

	@slot void fun() { }
}

string SIGNALS_AND_SLOTS(T)() {
	string data;
	static foreach(member, __traits(getMembers, T)) {
		static if(inArray(__traits(getAnnotations, member), "slot")) {
			data ~= "whatever implementation";
		}
	}

	return data;
}

==========


It is a little clunky, but it at least makes it accessible to libraries,
where they can figure out some way to work with it. It seems like it should
be fairly simple in the compiler - it is just keeping a list of strings.

> 
> Andrei

-- 
Adam D. Ruppe
http://arsdnet.net



More information about the Digitalmars-d mailing list