Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!softrue!kearns From: kearns@softrue.UUCP (Steven Kearns) Newsgroups: comp.lang.c++ Subject: typesafe downward casting Message-ID: <17.UUL1.3#8618@softrue.UUCP> Date: 29 Mar 91 15:45:40 GMT Organization: Software Truth Lines: 21 There has been much discussion lately about adding stuff to C++ so that people can assign a Base* to a Derived* without a cast. People feel "guilty" when they use a cast, as if they are doing something unsafe. If you look at things from a "program verification" viewpoint, the issue becomes much clearer. A cast of (Base*) to Derived* is just a function call that assumes that the Base* really points to a Derived*; if you can prove to yourself (and God) that this is so, then using the cast is perfectly safe, and you should not feel guilty. If we added stuff to C++ to take care of this "problem", then we would also have to add new types so that people do not call sqrt(x) when x is a negative number, or so they do not call a/b when b is 0. -steve ******************************************************** * Steven Kearns ....uunet!softrue!kearns * * Software Truth softrue!kearns@uunet.uu.net * ********************************************************