defered new feature
BCS
ao at pathlink.com
Thu Oct 23 11:11:23 PDT 2008
A number of times I have found my self wanting to have "new C(args)" return
a class derived from C. I know this can be done with a static function or
the like but syntactically, it's unappealing.
My suggestion is that, with some kind of flag, constructors be allowed and
required to construct an object and return it.
One use cases:
> class C
> {
> abstract void F(); /// abstract class
> abstract this(int i) /// "abstract" this is just one idea, others would
work as well
> {
> if(i < 0)
> return new N(-i);
> else
> return new P(i);
> }
> }
>
> private class N : C
> {
> void F();
> this(uint i){}
> }
>
> private class P : C
> {
> void F();
> this(uint i){}
> }
More information about the Digitalmars-d
mailing list