Re: convincing management to switch to Ocaml (fwd)

From: Anton Moscal (msk@tepkom.ru)
Date: Thu Sep 02 1999 - 14:38:21 MET DST


Date: Thu, 2 Sep 1999 16:38:21 +0400 (MSD)
From: Anton Moscal <msk@tepkom.ru>
To: Caml list <caml-list@pauillac.inria.fr>
Subject: Re: convincing management to switch to Ocaml (fwd)

On Fri, 27 Aug 1999, Andreas Rossberg wrote:

> > >For example, type safety,
> >
> > Wrong. C++ is type safe, provided you don't use casts.
>
> Wrong, due to pointer arithmetics. This can happen silently: e.g. the
> combination of arrays and subtyping as present in C++ is unsound, you
> can produce segmentation faults without using any casts or explicit
> pointer arithmetics or other features deemed unsafe. I think the basic
> example is even in one of Stroustrups books.

Another examples of C++ type unsafety:
   union types
   (...) function prototypes
!! hangling references (for example - to local variables)
   scalar delete instead of array deletion (and inverse)

And about templates & polymorphism:

one month ago I try to translate into C++ the following very
useful FP idiom (opeartor for postfix application):

let (+>) x f = f x

printf "%g" (1.0 +> sin +> cos);;

I wrote:

template <class A, class B, class C>
  C operator >> (B x, C (*f) (B)) { return (*f) (x); }
...

   printf ("%g", 1.0 >> sin >> cos);

It doesn't compiles (due to C++ restriction: one of the parameters of the
user-defined operator must be a class). This is good illustration of the
problems with usage advanced C++ features. Actually I can't find
any reasonable application in C++ for this template.

Regards,
Anton Moscal



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