__traits proposal: derive hierachy and current-scope-type or something
Christopher Wright
dhasenan at gmail.com
Fri Sep 21 16:31:17 PDT 2007
dennis luehring wrote:
> 1. derive-hierachy
>
> class A
> class B:A
> class C:A
> class D:C
>
> * derivedClasses - returns the derived classes
> (what about abstract/interface classes?)
>
> __traits( derivedClasses, "A" ) ==> [ B, C ]
> __traits( derivedClasses, "C" ) ==> [ D ]
// in file a.d
module a;
class A { }
class B : A { }
// set to ["B"]
const string[] a_derived = __traits(derivedClasses, "A");
// in file c.d
module c;
import a;
class C : A { }
// set to ["B"]
const string[] my_a_derived = a.a_derived;
It's a difficult relationship to get meaningfully and consistent.
> * baseClass (the upward version of derivedClasses)
>
> __traits( baseClass, "D" ) ==> [ C ]
> __traits( baseClass, "B" ) ==> [ A ]
This works reliably.
> should maybe work only in module-scope
For derivedClasses, it'd have to.
> 2. current-scope-type
>
> class bla
> {
> scope-type = in class bla
> void test()
> {
> scope-type = in class bla.test()
> }
> }
>
> maybe with line/module information
I don't get the purpose of this.
> only at compile-time
>
> ciao dennis
More information about the Digitalmars-d
mailing list