Re: convincing management to switch to Ocaml

From: John Skaller (
Date: Sun Aug 29 1999 - 08:08:40 MET DST

Message-Id: <>
Date: Sun, 29 Aug 1999 16:08:40 +1000
To: "Stefan Monnier" <monnier+lists/caml/news/>,
From: John Skaller <>
Subject: Re: convincing management to switch to Ocaml
In-Reply-To: <>

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:
                phone: 61-2-96600850
                snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:24 MET