covariance of 'out' parameters is crucial for polymorphism and function subtyping

2012-03-09 Thread Boscop
I noticed that D doesn't support covariant 'out' parameters, which breaks polymorphism that involves such functions, e.g.: --- // these classes' foo method returns via return value class A {A foo(){return new A;}} class B : A {B foo(){return new B;}} // these classes' foo method returns via out

Re: covariance of 'out' parameters is crucial for polymorphism and function subtyping

2012-03-09 Thread Walter Bright
On 3/9/2012 4:59 PM, Boscop wrote: It is crucial for function subtyping, because functions are only contravariant in their 'in' parameters, but covariant in their 'out' parameters and return type. Function subtyping matters not only in classes with methods that have 'out' parameters but also