Who's minister of propaganda this week?

Amit Patel amitp at Xenon.Stanford.EDU
Sun Mar 18 12:07:32 EST 2001


 Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
| 
| In many languages (Haskell, SML, OCaml, Clean, Mercury, Eiffel) they
| are almost never used. Again, not all languages are like C++ and Java
| where casting is essential.
| 

Type casting does not seem to be essential in C++ except when dealing
with low level interfaces (to the OS, usually through C libraries).
Unfortunately "cast" is used in two different ways in C and C++.
There is the type cast used to get around the type system.  For
example, (int)(some_pointer).  But ordinary conversions, such as
converting 3 to 3.0, or from Dog& to Animal&, are labelled "cast".
The former kind is the kind we want to stay away from, and is usually
reinterpret_cast in C++.  The latter is present in other languages but
isn't called a "cast" in those languages.

So yes, you could say casting (in the C sense) is essential in C++,
but in my experience, these essential casts are almost always safe
conversions and not the unsafe type casts.

In Java on the other hand, casting is essential when working with generic
container classes.  :-(

    - Amit
-- 
--
Amit J Patel, Computer Science Department, Stanford University
http://www-cs-students.stanford.edu/~amitp/



More information about the Python-list mailing list