Thread overview | |||||
---|---|---|---|---|---|
|
February 25, 2005 Rethinking implicit casts | ||||
---|---|---|---|---|
| ||||
http://msdn.microsoft.com/library/default.asp?url=/library/en- us/cpgenref/html/cpconcasts.asp clearly states, that implicit casting should not be made when one of the following holds 1. information is lost 2. a semantically different value is generated 3. the target belongs to another domain Although it is not precisely defined what a "domain" is or "semantically difference" I tend to follow this suggestions. The result would be, that unsigned values like `uint' are no more implicitely castable into signed values linke `int' and vice versa, that `float' can only be casted implicitely to `double' or `real' and `double' only to `real'. The link above also gives me the insight that my stunned glaring at the implicit casts from `int' to `char' and vice versa had a reason, when I first noticed them in C. How much congeniality to C is wishable for D despite of the stated dangerousness. -manfred |
February 27, 2005 Re: Rethinking implicit casts | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | Manfred Nowak wrote: > http://msdn.microsoft.com/library/default.asp?url=/library/en- > us/cpgenref/html/cpconcasts.asp clearly states, that implicit casting should not be made when one of the following holds > 1. information is lost > 2. a semantically different value is generated > 3. the target belongs to another domain > > Although it is not precisely defined what a "domain" is or "semantically difference" I tend to follow this suggestions. > > The result would be, that unsigned values like `uint' are no more implicitely castable into signed values linke `int' and vice versa, that `float' can only be casted implicitely to `double' or `real' and `double' only to `real'. This, and a few previous threads got me thinking. Casting, implicit casting, and overloading, I think, should always be considered together. In other words, in the future we shouldn't have threads about any one topic of these as such, but instead always try to look at all three in the threads. It's a pity that there's no word for it. (I.e. no word that means casting+implicitCasting+overloading.) All I can think of is "the type issue". :-( ps. the unfinished subject about function selection by return type should also be included in this. |
February 27, 2005 Re: Rethinking implicit casts | ||||
---|---|---|---|---|
| ||||
Posted in reply to Georg Wrede | "Georg Wrede" <georg.wrede@nospam.org> wrote in message news:42223786.4040407@nospam.org... > Manfred Nowak wrote: >> http://msdn.microsoft.com/library/default.asp?url=/library/en- >> us/cpgenref/html/cpconcasts.asp clearly states, that implicit casting >> should not be made when one of the following holds >> 1. information is lost >> 2. a semantically different value is generated >> 3. the target belongs to another domain >> >> Although it is not precisely defined what a "domain" is or "semantically difference" I tend to follow this suggestions. >> >> The result would be, that unsigned values like `uint' are no more implicitely castable into signed values linke `int' and vice versa, that `float' can only be casted implicitely to `double' or `real' and `double' only to `real'. > > This, and a few previous threads got me thinking. > > Casting, implicit casting, and overloading, I think, should always be considered together. In other words, in the future we shouldn't have threads about any one topic of these as such, but instead always try to look at all three in the threads. > > It's a pity that there's no word for it. (I.e. no word that means casting+implicitCasting+overloading.) Conversion |
Copyright © 1999-2021 by the D Language Foundation