D RTTI?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 5 15:28:30 PST 2012


On Mon, Mar 05, 2012 at 03:26:01PM -0800, H. S. Teoh wrote:
[...]
> 	template Serializable() {
> 		enum Serializable = q{
> 			static if (__traits(hasMember, typeof(this),
> 					"serializable"))
[...]

Ugh, that last string should read "serialize".


> 			{
> 				// Override existing method
> 				override void serialize(...);
> 			}
> 			else
> 			{
> 				// Insert missing method
> 				void serialize(...);
> 			}
> 		};
> 	}
> 
> 	class A {
> 		// This causes A to acquire serialize()
> 		mixin(Serializable!());
> 	}
> 
> 	class B : A {
> 		// This causes B to override serialize()
> 		mixin(Serializable!());
> 	}
> 
> 
> D is too cool for words.
> 
> 
> T
> 
> -- 
> For every argument for something, there is always an equal and opposite argument against it. Debates don't give answers, only wounded or inflated egos.

-- 
"How are you doing?" "Doing what?"


More information about the Digitalmars-d-learn mailing list