Suggestion: Implicit Derived[]-to-Base[] conversions should be disallowed

Kan ycgdqbttbvpw at mailinator.com
Mon Jan 29 00:48:20 PST 2007


>From the changelog:
> 0.72
> - Implicit conversions of B[] to A[] are now allowed if B is derived from A. 
> 0.73
> - Implicit conversions of B[] to A[] are no longer allowed if B is derived from A.
>   Gaping type safety holes are the reason. 

In the latest D 1.0, this kind of implicit conversion seems to be revived.
Were there any disucussions on the revival of this feature?

Im my understanding, such implicit conversion is a bad thing,
as Daniel Yokomiso has pointed out in the thread of DMD 0.72 release:

  http://www.digitalmars.com/d/archives/17039.html

Java does have such implicit conversions reluctantly, but it is only
because Java <=1.4 had lacked generics (and therefore lacked the power to
write generic array operations.) On the other hand, D has templates, so
we can write generic array operations by them, not relying on Derived[]-to-Base[] conversions.

What do you think?



More information about the Digitalmars-d mailing list