Re: convincing management to switch to Ocaml

From: John Skaller (skaller@maxtal.com.au)
Date: Sun Aug 29 1999 - 08:08:40 MET DST


Message-Id: <3.0.6.32.19990829160840.0096b2c0@mail.triode.net.au>
Date: Sun, 29 Aug 1999 16:08:40 +1000
To: "Stefan Monnier" <monnier+lists/caml/news/@tequila.cs.yale.edu>,
From: John Skaller <skaller@maxtal.com.au>
Subject: Re: convincing management to switch to Ocaml
In-Reply-To: <5lso56fkxn.fsf@tequila.cs.yale.edu>

At 14:36 26/08/99 -0400, Stefan Monnier wrote:
>>>>>> "John" == John Skaller <skaller@maxtal.com.au> 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



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