Re: On "type casting"



Stephen Sprunk wrote:
Han from China wrote:
There are people on this newsgroup who would blanket ban any use
of the term "type casting" in C, no matter what the context,
whether used in reference to an implicit conversion or an explicit
conversion. In other words, your use of "type cast" above to
refer to an explicit conversion is considered wrong by a number
of people on this newsgroup who think type casting is only what
actors do. They believe "cast" is correct but "type cast" isn't.

The Standard explicitly defines "cast" as an explicit conversion, so
that makes it automatically correct per clc dogma.

Depending on your views, "type cast" (or "typecast") is either incorrect
or, at best, redundant.

FWIW, typecasting is something done _to_ actors, not _by_ actors.

For the record, I think "explicit cast" is a redundancy as well,
since "cast" means "explicit conversion", but that's another
matter.

Right; "explicit cast" is again redundant, since casts are always
explicit. I'm more bothered by "implicit cast", but that shows the
symmetry in the misuse of "cast" to mean "conversion".

Yes, agreed in all respects. Being redundant just waters down the
original word. "Explicit cast" implies existence of an "implicit cast",
as "type cast" implies existence of some other kind of cast. Same for
things like cold/warm temperatures, long lengths, large/small sizes,
etc. which I often lose sleep over.

This kind of degradation occurs in other areas too; I was just reading a
C book in which the author used both "int* pointer" and "int pointer" to
refer to int*, which was odd as just pages later he was urging readers
to properly differentiate between "const pointer" (int* const) and
"pointer-to-const" (const int*).
.



Relevant Pages

  • Re: Terminology : casting/conversion
    ... Is this an "explicit" cast? ... and `void*', the conversion is implicit. ... (all operators are explicit). ...
    (comp.lang.c)
  • Re: cast to void *
    ... A cast is an explicit conversion. ... int main ...
    (comp.lang.c)
  • Re: bug in visual studio .net 2003 - breakpoints and memcpy
    ... No other conversion can be performed explicitly ... does the C standard say the same?). ... > So neither reinterpret_cast nor the explicit cast notation can be ... >> cast works it works. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: malloc and free
    ... C automatically converts a pointer to void to any ... > conversion" ... explicit: Fully and clearly expressed; ... The use of a cast operator is an explicit directive to the compiler to ...
    (comp.lang.c)
  • Re: malloc and free
    ... If it is explicit it is called a cast. ... I would call this type of conversion an implicit cast. ...
    (comp.lang.c)