[Issue 2295] automatically covariant types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 19 12:36:03 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2295





------- Comment #1 from shro8822 at vandals.uidaho.edu  2008-08-19 14:36 -------
That first bit is (and IMHO should be) invalid

{{{
B b=new B();
 b.methodA().methodB();
}}}

typeof(b.methodA()) == A
A has no .methodB

If you want the implied semantics I think there should be a substantially
different syntax.

The solution I would like to see would be an "automatically instanced template"
or "automatic mixin". This would be a (parameterless) template that is
automatically mixed into the given class and any derived class. This would let
you define methodA to have a return type of typeof(this) getting the hoped for
result. I have though of other cool thing to do with such a feature but, ATM, I
don't remember what.


-- 



More information about the Digitalmars-d-bugs mailing list