Re: Terminology : casting/conversion



In article <47gdufFf90qmU1@xxxxxxxxxxxxxx>
Richard G. Riley <rgrdev@xxxxxxxxx> wrote:
Would it be wrong to use "implicit casting" instead of the standards
"implicit conversion" when talking about implicit conversions between
certain data types.

It is certainly more consistent (and I think much less misleading)
to use the phrase "implicit conversion". This is because the C
standard defines "cast" as, in effect, "the syntactic construct
consisting of a parenthesized type-name followed by a value
expression, which causes an explicit conversion".

The "followed by a value" part is to handle C99's aggregate constants,
which use remarkably similar syntax, except that the parenthesized
type-name is followed by an open brace. That is:

(int)3.14159

uses a cast, but:

(int []){ 3, 1, 4, 1, 5, 9 }

does not -- the parenthesized type supplies the information needed
to construct the correct aggregate type, here "array 6 of int".
Note that the same sequence of six "int" constants might be used
to initialize something that is not an array at all:

struct zorg {
char a;
double b;
short c;
long d;
float e;
int f;
};
...
(struct zorg){ 3, 1, 4, 1, 5, 9 }

If a "cast" is nothing more than the explicit syntactic construct,
an "implicit cast" must be an "implicit explicit syntactic construct":
oxymoronic, like "large small" or "jumbo shrimp". :-)

(The last line above is meant more to point out that such things
do exist in English, and it would be possible for the C Standard
to define the phrase "implicit cast" as an alternative for "implicit
conversion". But it does not, and there is no need to clutter
one's vocabulary with Extra Alternative Options from the Bureau of
Redundancy Department.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
.



Relevant Pages

  • Re: new vs override - a practical example
    ... interpret it as without using the cast operator -- which is the issue here. ... * From any class-type S to any class-type T, provided S is derived from T. ... * From any class-type S to any interface-type T, ... Implicit conversion is exactly implicit. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why is this invalid
    ... is no implicit conversion between 'Test.IDerived1' and 'Test.IDerived2' ... Jon's solution is the correct one, although you don't need to cast ... them both (assuming that IBase is the base interface for both ... IDerived1 and IDerived2). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C/C++ guidelines
    ... So it's _not_ the usage of the cast which "might introduce ... subtle errors" but forgetting to include. ... Its a warning and no diagnosis is actually required. ... If you rely on getting a useful diagnostic for an implicit conversion ...
    (comp.lang.c)
  • Re: Terminology : casting/conversion
    ... It is certainly more consistent ... to use the phrase "implicit conversion". ... standard defines "cast" as, in effect, "the syntactic construct ...
    (comp.lang.c)
  • Re: Pass value of short type
    ... unsigned short into an unsigned int, ... be no warning, because the data will always fit. ... the implicit conversion is a promotion from unsigned short ... I agree you should avoid casts whenever possible (and especially avoid ...
    (comp.lang.cpp)