From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA30006 for caml-redistribution; Mon, 30 Aug 1999 15:53:00 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA30848 for ; Sun, 29 Aug 1999 08:07:41 +0200 (MET DST) Received: from iggy.triode.net.au (iggy.triode.net.au [203.63.235.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id IAA27762 for ; Sun, 29 Aug 1999 08:07:37 +0200 (MET DST) Received: from egret (pm1-23.triode.net.au [203.63.235.39]) by iggy.triode.net.au (8.9.3/8.8.8) with SMTP id QAA05869; Sun, 29 Aug 1999 16:04:49 +1000 Message-Id: <3.0.6.32.19990829160840.0096b2c0@mail.triode.net.au> X-Sender: skaller@mail.triode.net.au X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Sun, 29 Aug 1999 16:08:40 +1000 To: "Stefan Monnier" , caml-list@inria.fr From: John Skaller Subject: Re: convincing management to switch to Ocaml In-Reply-To: <5lso56fkxn.fsf@tequila.cs.yale.edu> References: <3.0.6.32.19990813203205.00990520@mail.triode.net.au> <001801beee9c$5d364860$0150ebca@nextsolution.co.jp> <3.0.6.32.19990825135019.009a8990@mail.triode.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: weis At 14:36 26/08/99 -0400, Stefan Monnier wrote: >>>>>> "John" == John Skaller writes: >> Wrong. C++ is type safe, provided you don't use casts. > >And several other C constructs like unions, arrays, varargs, manual >memory management, ... Technically you are right for unions: however, I'd consider using a union component 'equivalent to a cast'. However, it isn't greppable like a cast, so you are right. C arrays are type safe, but the C conversion of an array lvalue to a pointer to an array is not type safe in the presence of classes when the array type is a derived type, so you are also right there. Varargs macros are specially hacked up kinds of casts, but again, you're technically correct. The case of stuffed up memory management leading to a run time fault not really related to the type system (just like indexing past the end of an array). There is, however, a special exception to this, where you are right: Y *y = new X[n]; // upcast to base class del x; // hole in type system but this is really the _same_ hole as before, due to the conversion of an array to a pointer. There is, in fact ANOTHER hole: Y *y = new X; del y; which will fail if X doesn't have a virtual destructor. ------------------------ Given the list of things that are unsafe in C++, I withdraw my claim that C++ is typesafe, provided you don't use casts. The list of caveats is much longer. [Ugh] ------------------------------------------------------- John Skaller email: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia