No more implicit conversion real->complex?!
Sean Kelly
sean at f4.ca
Wed Mar 22 09:13:06 PST 2006
Don Clugston wrote:
> kris wrote:
>>
>> Thus the nobility of "C compatability" is perhaps just a bit thin?
>> Wouldn't it be nice to tidy some of this up while the opportunity
>> presents itself?
>
> I think you're right. I think the "C compatibility" argument is relevant
> only for cases where changes would be very common and hard to track down.
> (FWIW, I've converted the Cephes math libraries from C to D. In every
> case, the tighter D language rules improved the code).
>
> I haven't done much work with char/wchar/dchar in D, so I don't have
> much idea of how troublesome the implicit conversions are. Undoubtedly
> you have the most experience here. If you're also finding them to be a
> nuisance rather than a convenience, we should
>
> It does seem to me that implicit widening conversions are nearly always
> helpful, but those ones that change the semantics (wchar->short,
> real->creal, etc) seem much more likely to be annoying. I particularly
> dislike conversions that silently insert code.
I think it might be ideal to allow implicit widening conversions between
char types but to disallow promotion from char to integer types. One
might argue that math with chars is routinely performed in C, but
outside the ASCII character set I don't see that being particularly
useful in D. I'd be willing to live with the need for an explicit cast
to ubyte/ushort/uint in D, as it seems more meaningful.
> The suggestion was made to have two levels of implicit conversion,
> roughly similar to the promotion rules, ie:
>
> * exact match
> * match with implicit widening conversions
> * match with implicit semantic-changing conversions.
>
> Would this improve the situation for char/int conversions?
I think it might.
Sean
More information about the Digitalmars-d
mailing list