On Sunday, 9 November 2014 at 21:47:03 UTC, eles wrote:
On Sunday, 9 November 2014 at 19:00:01 UTC, tcak wrote:
I am also strongly in favor of introducing an "uncast". For
example, in C++'x const_cast and in D's cast for removing, for
example immutability:
immutable int* p = ...;
int* q = cast(int*)p;
I think the goal is not clearly expressed with this cast. It
does not show that it's intension is to remove immutability and
otherwise let that type unchanged. If later a mismatch is
introduced between the left and the right type of data, that
inoffensive cast could create problems by hiding an error that
should have been spotted.
Something like that would be more expressive:
immutable int* p = ...;
int* q = uncast(immutable)p;
//or
int* q = cast(~immutable)p;
This way, invalid implicit conversions from p's type to q's
type would be spotted.
Well, my question was actually on-purpose automatic casting.
Something like:
b = autocast( a );
Because I am auto casting with a keyword, compiler shouldn't
complain about it as well. This can also solve "uncast" thing.